From dafff52ffeb829635ed0228d214a1ddcb8eff809 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Tue, 7 May 2024 09:36:38 +0000 Subject: [PATCH] Updating based on a0808d0a --- .../2024-05-01/accessconnector/README.md | 117 +++ .../2024-05-01/accessconnector/client.go | 26 + .../2024-05-01/accessconnector/constants.go | 54 ++ .../accessconnector/id_accessconnector.go | 130 ++++ .../id_accessconnector_test.go | 282 ++++++++ .../accessconnector/method_createorupdate.go | 75 ++ .../accessconnector/method_delete.go | 71 ++ .../2024-05-01/accessconnector/method_get.go | 54 ++ .../method_listbyresourcegroup.go | 92 +++ .../method_listbysubscription.go | 92 +++ .../accessconnector/method_update.go | 75 ++ .../accessconnector/model_accessconnector.go | 20 + .../model_accessconnectorproperties.go | 9 + .../model_accessconnectorupdate.go | 13 + .../2024-05-01/accessconnector/predicates.go | 32 + .../2024-05-01/accessconnector/version.go | 12 + .../databricks/2024-05-01/client.go | 91 +++ .../databricks/2024-05-01/delete/client.go | 26 + .../delete/id_privateendpointconnection.go | 139 ++++ .../id_privateendpointconnection_test.go | 327 +++++++++ ...method_privateendpointconnectionsdelete.go | 71 ++ .../databricks/2024-05-01/delete/version.go | 12 + .../README.md | 36 + .../client.go | 26 + .../id_workspace.go | 130 ++++ .../id_workspace_test.go | 282 ++++++++ .../method_list.go | 55 ++ .../model_endpointdependency.go | 9 + .../model_endpointdetail.go | 11 + .../model_outboundenvironmentendpoint.go | 9 + .../version.go | 12 + .../privateendpointconnections/README.md | 82 +++ .../privateendpointconnections/client.go | 26 + .../privateendpointconnections/constants.go | 107 +++ .../id_privateendpointconnection.go | 139 ++++ .../id_privateendpointconnection_test.go | 327 +++++++++ .../id_workspace.go | 130 ++++ .../id_workspace_test.go | 282 ++++++++ .../method_create.go | 75 ++ .../method_delete.go | 71 ++ .../privateendpointconnections/method_get.go | 54 ++ .../privateendpointconnections/method_list.go | 91 +++ .../model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 11 + ...del_privateendpointconnectionproperties.go | 11 + ...model_privatelinkserviceconnectionstate.go | 10 + .../privateendpointconnections/predicates.go | 27 + .../privateendpointconnections/version.go | 12 + .../2024-05-01/privatelinkresources/README.md | 53 ++ .../2024-05-01/privatelinkresources/client.go | 26 + .../id_privatelinkresource.go | 139 ++++ .../id_privatelinkresource_test.go | 327 +++++++++ .../privatelinkresources/id_workspace.go | 130 ++++ .../privatelinkresources/id_workspace_test.go | 282 ++++++++ .../privatelinkresources/method_get.go | 54 ++ .../privatelinkresources/method_list.go | 91 +++ .../model_groupidinformation.go | 11 + .../model_groupidinformationproperties.go | 10 + .../privatelinkresources/predicates.go | 27 + .../privatelinkresources/version.go | 12 + .../databricks/2024-05-01/put/README.md | 37 + .../databricks/2024-05-01/put/client.go | 26 + .../databricks/2024-05-01/put/constants.go | 107 +++ .../put/id_privateendpointconnection.go | 139 ++++ .../put/id_privateendpointconnection_test.go | 327 +++++++++ ...method_privateendpointconnectionscreate.go | 75 ++ .../2024-05-01/put/model_privateendpoint.go | 8 + .../put/model_privateendpointconnection.go | 11 + ...del_privateendpointconnectionproperties.go | 11 + ...model_privatelinkserviceconnectionstate.go | 10 + .../databricks/2024-05-01/put/version.go | 12 + .../2024-05-01/vnetpeering/README.md | 82 +++ .../2024-05-01/vnetpeering/client.go | 26 + .../2024-05-01/vnetpeering/constants.go | 101 +++ .../vnetpeering/id_virtualnetworkpeering.go | 139 ++++ .../id_virtualnetworkpeering_test.go | 327 +++++++++ .../2024-05-01/vnetpeering/id_workspace.go | 130 ++++ .../vnetpeering/id_workspace_test.go | 282 ++++++++ .../vnetpeering/method_createorupdate.go | 75 ++ .../2024-05-01/vnetpeering/method_delete.go | 71 ++ .../2024-05-01/vnetpeering/method_get.go | 55 ++ .../vnetpeering/method_listbyworkspace.go | 91 +++ .../vnetpeering/model_addressspace.go | 8 + .../model_virtualnetworkpeering.go | 11 + ...l_virtualnetworkpeeringpropertiesformat.go | 17 + ...ropertiesformatdatabricksvirtualnetwork.go | 8 + ...ingpropertiesformatremotevirtualnetwork.go | 8 + .../2024-05-01/vnetpeering/predicates.go | 27 + .../2024-05-01/vnetpeering/version.go | 12 + .../2024-05-01/workspaces/README.md | 117 +++ .../2024-05-01/workspaces/client.go | 26 + .../2024-05-01/workspaces/constants.go | 673 ++++++++++++++++++ .../2024-05-01/workspaces/id_workspace.go | 130 ++++ .../workspaces/id_workspace_test.go | 282 ++++++++ .../workspaces/method_createorupdate.go | 75 ++ .../2024-05-01/workspaces/method_delete.go | 99 +++ .../2024-05-01/workspaces/method_get.go | 54 ++ .../workspaces/method_listbyresourcegroup.go | 92 +++ .../workspaces/method_listbysubscription.go | 92 +++ .../2024-05-01/workspaces/method_update.go | 75 ++ .../model_automaticclusterupdatedefinition.go | 8 + ...del_compliancesecurityprofiledefinition.go | 9 + .../2024-05-01/workspaces/model_createdby.go | 10 + .../model_defaultcatalogproperties.go | 9 + .../2024-05-01/workspaces/model_encryption.go | 11 + .../model_encryptionentitiesdefinition.go | 9 + .../workspaces/model_encryptionv2.go | 9 + .../model_encryptionv2keyvaultproperties.go | 10 + ...el_enhancedsecuritycompliancedefinition.go | 10 + ...el_enhancedsecuritymonitoringdefinition.go | 8 + .../workspaces/model_manageddiskencryption.go | 10 + ...manageddiskencryptionkeyvaultproperties.go | 10 + .../model_managedidentityconfiguration.go | 10 + .../workspaces/model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 11 + ...del_privateendpointconnectionproperties.go | 11 + ...model_privatelinkserviceconnectionstate.go | 10 + .../2024-05-01/workspaces/model_sku.go | 9 + .../2024-05-01/workspaces/model_workspace.go | 19 + .../model_workspacecustombooleanparameter.go | 9 + .../model_workspacecustomobjectparameter.go | 9 + .../model_workspacecustomparameters.go | 23 + .../model_workspacecustomstringparameter.go | 9 + .../model_workspaceencryptionparameter.go | 9 + ...del_workspacenopublicipbooleanparameter.go | 9 + .../workspaces/model_workspaceproperties.go | 47 ++ ...odel_workspacepropertiesaccessconnector.go | 10 + .../model_workspacepropertiesencryption.go | 8 + .../model_workspaceproviderauthorization.go | 9 + .../workspaces/model_workspaceupdate.go | 8 + .../2024-05-01/workspaces/predicates.go | 32 + .../2024-05-01/workspaces/version.go | 12 + .../2024-04-01/attacheddatanetwork/README.md | 86 +++ .../2024-04-01/attacheddatanetwork/client.go | 26 + .../attacheddatanetwork/constants.go | 107 +++ .../id_attacheddatanetwork.go | 148 ++++ .../id_attacheddatanetwork_test.go | 372 ++++++++++ .../method_createorupdate.go | 75 ++ .../attacheddatanetwork/method_delete.go | 71 ++ .../attacheddatanetwork/method_get.go | 54 ++ .../attacheddatanetwork/method_updatetags.go | 58 ++ .../model_attacheddatanetwork.go | 18 + ...del_attacheddatanetworkpropertiesformat.go | 13 + .../model_interfaceproperties.go | 14 + .../model_naptconfiguration.go | 12 + .../model_pinholetimeouts.go | 10 + .../attacheddatanetwork/model_portrange.go | 9 + .../model_portreuseholdtimes.go | 9 + .../attacheddatanetwork/model_tagsobject.go | 8 + .../2024-04-01/attacheddatanetwork/version.go | 12 + .../2024-04-01/attacheddatanetworks/README.md | 37 + .../2024-04-01/attacheddatanetworks/client.go | 26 + .../attacheddatanetworks/constants.go | 107 +++ .../id_packetcoredataplane.go | 139 ++++ .../id_packetcoredataplane_test.go | 327 +++++++++ .../method_listbypacketcoredataplane.go | 91 +++ .../model_attacheddatanetwork.go | 18 + ...del_attacheddatanetworkpropertiesformat.go | 13 + .../model_interfaceproperties.go | 14 + .../model_naptconfiguration.go | 12 + .../model_pinholetimeouts.go | 10 + .../attacheddatanetworks/model_portrange.go | 9 + .../model_portreuseholdtimes.go | 9 + .../attacheddatanetworks/predicates.go | 32 + .../attacheddatanetworks/version.go | 12 + .../mobilenetwork/2024-04-01/client.go | 298 ++++++++ .../2024-04-01/datanetwork/README.md | 86 +++ .../2024-04-01/datanetwork/client.go | 26 + .../2024-04-01/datanetwork/constants.go | 66 ++ .../2024-04-01/datanetwork/id_datanetwork.go | 139 ++++ .../datanetwork/id_datanetwork_test.go | 327 +++++++++ .../datanetwork/method_createorupdate.go | 75 ++ .../2024-04-01/datanetwork/method_delete.go | 71 ++ .../2024-04-01/datanetwork/method_get.go | 54 ++ .../datanetwork/method_updatetags.go | 58 ++ .../datanetwork/model_datanetwork.go | 18 + .../model_datanetworkpropertiesformat.go | 9 + .../datanetwork/model_tagsobject.go | 8 + .../2024-04-01/datanetwork/version.go | 12 + .../2024-04-01/datanetworks/README.md | 37 + .../2024-04-01/datanetworks/client.go | 26 + .../2024-04-01/datanetworks/constants.go | 66 ++ .../datanetworks/id_mobilenetwork.go | 130 ++++ .../datanetworks/id_mobilenetwork_test.go | 282 ++++++++ .../method_listbymobilenetwork.go | 91 +++ .../datanetworks/model_datanetwork.go | 18 + .../model_datanetworkpropertiesformat.go | 9 + .../2024-04-01/datanetworks/predicates.go | 32 + .../2024-04-01/datanetworks/version.go | 12 + .../2024-04-01/diagnosticspackages/README.md | 77 ++ .../2024-04-01/diagnosticspackages/client.go | 26 + .../diagnosticspackages/constants.go | 113 +++ .../id_diagnosticspackage.go | 139 ++++ .../id_diagnosticspackage_test.go | 327 +++++++++ .../id_packetcorecontrolplane.go | 130 ++++ .../id_packetcorecontrolplane_test.go | 282 ++++++++ .../method_createorupdate.go | 71 ++ .../diagnosticspackages/method_delete.go | 71 ++ .../diagnosticspackages/method_get.go | 54 ++ .../method_listbypacketcorecontrolplane.go | 91 +++ .../model_diagnosticspackage.go | 16 + ...odel_diagnosticspackagepropertiesformat.go | 10 + .../diagnosticspackages/predicates.go | 27 + .../2024-04-01/diagnosticspackages/version.go | 12 + .../extendedueinformation/README.md | 36 + .../extendedueinformation/client.go | 26 + .../extendedueinformation/constants.go | 233 ++++++ .../2024-04-01/extendedueinformation/id_ue.go | 139 ++++ .../extendedueinformation/id_ue_test.go | 327 +++++++++ .../extendedueinformation/method_get.go | 55 ++ .../extendedueinformation/model_ambr.go | 9 + .../extendedueinformation/model_amfid.go | 10 + .../model_extendedueinfo.go | 48 ++ .../model_extendedueinfoproperties.go | 61 ++ .../model_globalrannodeid.go | 15 + .../extendedueinformation/model_gnbid.go | 9 + .../extendedueinformation/model_guti4g.go | 10 + .../extendedueinformation/model_guti5g.go | 10 + .../extendedueinformation/model_mmeid.go | 9 + .../extendedueinformation/model_plmnid.go | 9 + .../extendedueinformation/model_snssai.go | 9 + .../model_ueconnectioninfo4g.go | 35 + .../model_ueconnectioninfo5g.go | 36 + .../extendedueinformation/model_ueinfo4g.go | 57 ++ .../model_ueinfo4gproperties.go | 13 + .../extendedueinformation/model_ueinfo5g.go | 57 ++ .../model_ueinfo5gproperties.go | 12 + .../model_ueipaddress.go | 8 + .../model_uelocationinfo.go | 10 + .../extendedueinformation/model_ueqosflow.go | 11 + .../model_uesessioninfo4g.go | 11 + .../model_uesessioninfo5g.go | 14 + .../extendedueinformation/version.go | 12 + .../2024-04-01/mobilenetwork/README.md | 86 +++ .../2024-04-01/mobilenetwork/client.go | 26 + .../2024-04-01/mobilenetwork/constants.go | 66 ++ .../mobilenetwork/id_mobilenetwork.go | 130 ++++ .../mobilenetwork/id_mobilenetwork_test.go | 282 ++++++++ .../mobilenetwork/method_createorupdate.go | 75 ++ .../2024-04-01/mobilenetwork/method_delete.go | 71 ++ .../2024-04-01/mobilenetwork/method_get.go | 54 ++ .../mobilenetwork/method_updatetags.go | 58 ++ .../model_homenetworkpublickey.go | 9 + .../model_identityandtagsobject.go | 13 + .../mobilenetwork/model_mobilenetwork.go | 20 + .../model_mobilenetworkpropertiesformat.go | 11 + .../2024-04-01/mobilenetwork/model_plmnid.go | 9 + .../model_publiclandmobilenetwork.go | 10 + ...clandmobilenetworkhomenetworkpublickeys.go | 9 + .../2024-04-01/mobilenetwork/version.go | 12 + .../2024-04-01/mobilenetworks/README.md | 72 ++ .../2024-04-01/mobilenetworks/client.go | 26 + .../2024-04-01/mobilenetworks/constants.go | 66 ++ .../mobilenetworks/id_mobilenetwork.go | 130 ++++ .../mobilenetworks/id_mobilenetwork_test.go | 282 ++++++++ .../method_listbyresourcegroup.go | 92 +++ .../method_listbysubscription.go | 92 +++ .../mobilenetworks/method_listsimgroups.go | 91 +++ .../model_homenetworkpublickey.go | 9 + .../mobilenetworks/model_keyvaultkey.go | 8 + .../mobilenetworks/model_mobilenetwork.go | 20 + .../model_mobilenetworkpropertiesformat.go | 11 + .../model_mobilenetworkresourceid.go | 8 + .../2024-04-01/mobilenetworks/model_plmnid.go | 9 + .../model_publiclandmobilenetwork.go | 10 + ...clandmobilenetworkhomenetworkpublickeys.go | 9 + .../mobilenetworks/model_simgroup.go | 20 + .../model_simgrouppropertiesformat.go | 10 + .../2024-04-01/mobilenetworks/predicates.go | 60 ++ .../2024-04-01/mobilenetworks/version.go | 12 + .../2024-04-01/packetcaptures/README.md | 94 +++ .../2024-04-01/packetcaptures/client.go | 26 + .../2024-04-01/packetcaptures/constants.go | 113 +++ .../packetcaptures/id_packetcapture.go | 139 ++++ .../packetcaptures/id_packetcapture_test.go | 327 +++++++++ .../id_packetcorecontrolplane.go | 130 ++++ .../id_packetcorecontrolplane_test.go | 282 ++++++++ .../packetcaptures/method_createorupdate.go | 75 ++ .../packetcaptures/method_delete.go | 71 ++ .../2024-04-01/packetcaptures/method_get.go | 54 ++ .../method_listbypacketcorecontrolplane.go | 91 +++ .../2024-04-01/packetcaptures/method_stop.go | 71 ++ .../model_asyncoperationstatus.go | 46 ++ .../model_erroradditionalinfo.go | 9 + .../packetcaptures/model_errordetail.go | 12 + .../packetcaptures/model_packetcapture.go | 16 + .../model_packetcapturepropertiesformat.go | 34 + .../2024-04-01/packetcaptures/predicates.go | 27 + .../2024-04-01/packetcaptures/version.go | 12 + .../packetcorecontrolplane/README.md | 86 +++ .../packetcorecontrolplane/client.go | 26 + .../packetcorecontrolplane/constants.go | 580 +++++++++++++++ .../id_packetcorecontrolplane.go | 130 ++++ .../id_packetcorecontrolplane_test.go | 282 ++++++++ .../method_createorupdate.go | 75 ++ .../packetcorecontrolplane/method_delete.go | 71 ++ .../packetcorecontrolplane/method_get.go | 54 ++ .../method_updatetags.go | 58 ++ .../model_asyncoperationid.go | 8 + .../model_azurestackedgedeviceresourceid.go | 8 + .../model_azurestackhciclusterresourceid.go | 8 + .../model_certificateprovisioning.go | 9 + .../model_connectedclusterresourceid.go | 8 + .../model_customlocationresourceid.go | 8 + .../model_diagnosticsuploadconfiguration.go | 8 + .../model_eventhubconfiguration.go | 9 + ...odel_homenetworkprivatekeysprovisioning.go | 8 + .../model_httpsservercertificate.go | 9 + .../model_identityandtagsobject.go | 13 + .../model_installation.go | 12 + .../model_interfaceproperties.go | 14 + ...del_localdiagnosticsaccessconfiguration.go | 9 + .../model_nasrerouteconfiguration.go | 8 + .../model_packetcorecontrolplane.go | 20 + ..._packetcorecontrolplanepropertiesformat.go | 26 + .../model_platformconfiguration.go | 13 + .../model_signalingconfiguration.go | 9 + .../model_siteresourceid.go | 8 + .../model_userconsentconfiguration.go | 8 + .../packetcorecontrolplane/version.go | 12 + .../README.md | 37 + .../client.go | 26 + .../id_packetcorecontrolplane.go | 130 ++++ .../id_packetcorecontrolplane_test.go | 282 ++++++++ ...econtrolplanescollectdiagnosticspackage.go | 75 ++ .../model_asyncoperationstatus.go | 46 ++ .../model_erroradditionalinfo.go | 9 + .../model_errordetail.go | 12 + ...recontrolplanecollectdiagnosticspackage.go | 8 + .../version.go | 12 + .../packetcorecontrolplanereinstall/README.md | 32 + .../packetcorecontrolplanereinstall/client.go | 26 + .../id_packetcorecontrolplane.go | 130 ++++ .../id_packetcorecontrolplane_test.go | 282 ++++++++ ...method_packetcorecontrolplanesreinstall.go | 71 ++ .../model_asyncoperationstatus.go | 46 ++ .../model_erroradditionalinfo.go | 9 + .../model_errordetail.go | 12 + .../version.go | 12 + .../packetcorecontrolplanerollback/README.md | 32 + .../packetcorecontrolplanerollback/client.go | 26 + .../id_packetcorecontrolplane.go | 130 ++++ .../id_packetcorecontrolplane_test.go | 282 ++++++++ .../method_packetcorecontrolplanesrollback.go | 71 ++ .../model_asyncoperationstatus.go | 46 ++ .../model_erroradditionalinfo.go | 9 + .../model_errordetail.go | 12 + .../packetcorecontrolplanerollback/version.go | 12 + .../packetcorecontrolplanes/README.md | 55 ++ .../packetcorecontrolplanes/client.go | 26 + .../packetcorecontrolplanes/constants.go | 580 +++++++++++++++ .../method_listbyresourcegroup.go | 92 +++ .../method_listbysubscription.go | 92 +++ .../model_asyncoperationid.go | 8 + .../model_azurestackedgedeviceresourceid.go | 8 + .../model_azurestackhciclusterresourceid.go | 8 + .../model_certificateprovisioning.go | 9 + .../model_connectedclusterresourceid.go | 8 + .../model_customlocationresourceid.go | 8 + .../model_diagnosticsuploadconfiguration.go | 8 + .../model_eventhubconfiguration.go | 9 + ...odel_homenetworkprivatekeysprovisioning.go | 8 + .../model_httpsservercertificate.go | 9 + .../model_installation.go | 12 + .../model_interfaceproperties.go | 14 + ...del_localdiagnosticsaccessconfiguration.go | 9 + .../model_nasrerouteconfiguration.go | 8 + .../model_packetcorecontrolplane.go | 20 + ..._packetcorecontrolplanepropertiesformat.go | 26 + .../model_platformconfiguration.go | 13 + .../model_signalingconfiguration.go | 9 + .../model_siteresourceid.go | 8 + .../model_userconsentconfiguration.go | 8 + .../packetcorecontrolplanes/predicates.go | 32 + .../packetcorecontrolplanes/version.go | 12 + .../packetcorecontrolplaneversion/README.md | 87 +++ .../packetcorecontrolplaneversion/client.go | 26 + .../constants.go | 242 +++++++ .../id_packetcorecontrolplaneversion.go | 112 +++ .../id_packetcorecontrolplaneversion_test.go | 192 +++++ ...d_providerpacketcorecontrolplaneversion.go | 121 ++++ ...viderpacketcorecontrolplaneversion_test.go | 237 ++++++ .../method_get.go | 54 ++ .../method_getbysubscription.go | 54 ++ .../method_list.go | 91 +++ .../method_listbysubscription.go | 92 +++ .../model_packetcorecontrolplaneversion.go | 16 + ...corecontrolplaneversionpropertiesformat.go | 9 + .../model_platform.go | 14 + .../predicates.go | 27 + .../packetcorecontrolplaneversion/version.go | 12 + .../2024-04-01/packetcoredataplane/README.md | 86 +++ .../2024-04-01/packetcoredataplane/client.go | 26 + .../packetcoredataplane/constants.go | 66 ++ .../id_packetcoredataplane.go | 139 ++++ .../id_packetcoredataplane_test.go | 327 +++++++++ .../method_createorupdate.go | 75 ++ .../packetcoredataplane/method_delete.go | 71 ++ .../packetcoredataplane/method_get.go | 54 ++ .../packetcoredataplane/method_updatetags.go | 58 ++ .../model_interfaceproperties.go | 14 + .../model_packetcoredataplane.go | 18 + ...del_packetcoredataplanepropertiesformat.go | 10 + .../packetcoredataplane/model_tagsobject.go | 8 + .../2024-04-01/packetcoredataplane/version.go | 12 + .../2024-04-01/packetcoredataplanes/README.md | 37 + .../2024-04-01/packetcoredataplanes/client.go | 26 + .../packetcoredataplanes/constants.go | 66 ++ .../id_packetcorecontrolplane.go | 130 ++++ .../id_packetcorecontrolplane_test.go | 282 ++++++++ .../method_listbypacketcorecontrolplane.go | 91 +++ .../model_interfaceproperties.go | 14 + .../model_packetcoredataplane.go | 18 + ...del_packetcoredataplanepropertiesformat.go | 10 + .../packetcoredataplanes/predicates.go | 32 + .../packetcoredataplanes/version.go | 12 + .../2024-04-01/routinginfo/README.md | 53 ++ .../2024-04-01/routinginfo/client.go | 26 + .../routinginfo/id_packetcorecontrolplane.go | 130 ++++ .../id_packetcorecontrolplane_test.go | 282 ++++++++ .../2024-04-01/routinginfo/method_get.go | 55 ++ .../2024-04-01/routinginfo/method_list.go | 91 +++ .../model_attacheddatanetworkresourceid.go | 8 + .../2024-04-01/routinginfo/model_ipv4route.go | 9 + .../routinginfo/model_ipv4routenexthop.go | 9 + .../routinginfo/model_routinginfomodel.go | 16 + .../model_routinginfopropertiesformat.go | 10 + ...anedataroutesuserplanedataroutesinlined.go | 9 + .../2024-04-01/routinginfo/predicates.go | 27 + .../2024-04-01/routinginfo/version.go | 12 + .../2024-04-01/service/README.md | 86 +++ .../2024-04-01/service/client.go | 26 + .../2024-04-01/service/constants.go | 233 ++++++ .../2024-04-01/service/id_service.go | 139 ++++ .../2024-04-01/service/id_service_test.go | 327 +++++++++ .../service/method_createorupdate.go | 75 ++ .../2024-04-01/service/method_delete.go | 71 ++ .../2024-04-01/service/method_get.go | 54 ++ .../2024-04-01/service/method_updatetags.go | 58 ++ .../2024-04-01/service/model_ambr.go | 9 + .../service/model_pccruleconfiguration.go | 12 + .../service/model_pccruleqospolicy.go | 13 + .../2024-04-01/service/model_qospolicy.go | 12 + .../2024-04-01/service/model_service.go | 18 + .../service/model_servicedataflowtemplate.go | 12 + .../service/model_servicepropertiesformat.go | 11 + .../2024-04-01/service/model_tagsobject.go | 8 + .../2024-04-01/service/version.go | 12 + .../2024-04-01/services/README.md | 37 + .../2024-04-01/services/client.go | 26 + .../2024-04-01/services/constants.go | 233 ++++++ .../2024-04-01/services/id_mobilenetwork.go | 130 ++++ .../services/id_mobilenetwork_test.go | 282 ++++++++ .../services/method_listbymobilenetwork.go | 91 +++ .../2024-04-01/services/model_ambr.go | 9 + .../services/model_pccruleconfiguration.go | 12 + .../services/model_pccruleqospolicy.go | 13 + .../2024-04-01/services/model_qospolicy.go | 12 + .../2024-04-01/services/model_service.go | 18 + .../services/model_servicedataflowtemplate.go | 12 + .../services/model_servicepropertiesformat.go | 11 + .../2024-04-01/services/predicates.go | 32 + .../2024-04-01/services/version.go | 12 + .../mobilenetwork/2024-04-01/sim/README.md | 65 ++ .../mobilenetwork/2024-04-01/sim/client.go | 26 + .../mobilenetwork/2024-04-01/sim/constants.go | 163 +++++ .../mobilenetwork/2024-04-01/sim/id_sim.go | 139 ++++ .../2024-04-01/sim/id_sim_test.go | 327 +++++++++ .../2024-04-01/sim/method_createorupdate.go | 75 ++ .../2024-04-01/sim/method_delete.go | 71 ++ .../2024-04-01/sim/method_get.go | 54 ++ .../model_attacheddatanetworkresourceid.go | 8 + .../mobilenetwork/2024-04-01/sim/model_sim.go | 16 + .../sim/model_simpolicyresourceid.go | 8 + .../sim/model_simpropertiesformat.go | 19 + .../sim/model_simstaticipproperties.go | 10 + .../model_simstaticippropertiesstaticip.go | 8 + .../2024-04-01/sim/model_sliceresourceid.go | 8 + .../mobilenetwork/2024-04-01/sim/version.go | 12 + .../2024-04-01/simgroup/README.md | 86 +++ .../2024-04-01/simgroup/client.go | 26 + .../2024-04-01/simgroup/constants.go | 66 ++ .../2024-04-01/simgroup/id_simgroup.go | 130 ++++ .../2024-04-01/simgroup/id_simgroup_test.go | 282 ++++++++ .../simgroup/method_createorupdate.go | 75 ++ .../2024-04-01/simgroup/method_delete.go | 71 ++ .../2024-04-01/simgroup/method_get.go | 54 ++ .../2024-04-01/simgroup/method_updatetags.go | 58 ++ .../simgroup/model_identityandtagsobject.go | 13 + .../2024-04-01/simgroup/model_keyvaultkey.go | 8 + .../simgroup/model_mobilenetworkresourceid.go | 8 + .../2024-04-01/simgroup/model_simgroup.go | 20 + .../model_simgrouppropertiesformat.go | 10 + .../2024-04-01/simgroup/version.go | 12 + .../2024-04-01/simgroups/README.md | 55 ++ .../2024-04-01/simgroups/client.go | 26 + .../2024-04-01/simgroups/constants.go | 66 ++ .../simgroups/method_listbyresourcegroup.go | 92 +++ .../simgroups/method_listbysubscription.go | 92 +++ .../2024-04-01/simgroups/model_keyvaultkey.go | 8 + .../model_mobilenetworkresourceid.go | 8 + .../2024-04-01/simgroups/model_simgroup.go | 20 + .../model_simgrouppropertiesformat.go | 10 + .../2024-04-01/simgroups/predicates.go | 32 + .../2024-04-01/simgroups/version.go | 12 + .../2024-04-01/simpolicies/README.md | 37 + .../2024-04-01/simpolicies/client.go | 26 + .../2024-04-01/simpolicies/constants.go | 242 +++++++ .../simpolicies/id_mobilenetwork.go | 130 ++++ .../simpolicies/id_mobilenetwork_test.go | 282 ++++++++ .../simpolicies/method_listbymobilenetwork.go | 91 +++ .../2024-04-01/simpolicies/model_ambr.go | 9 + .../model_datanetworkconfiguration.go | 17 + .../model_datanetworkresourceid.go | 8 + .../simpolicies/model_serviceresourceid.go | 8 + .../2024-04-01/simpolicies/model_simpolicy.go | 18 + .../model_simpolicypropertiesformat.go | 14 + .../simpolicies/model_sliceconfiguration.go | 10 + .../simpolicies/model_sliceresourceid.go | 8 + .../2024-04-01/simpolicies/predicates.go | 32 + .../2024-04-01/simpolicies/version.go | 12 + .../2024-04-01/simpolicy/README.md | 86 +++ .../2024-04-01/simpolicy/client.go | 26 + .../2024-04-01/simpolicy/constants.go | 242 +++++++ .../2024-04-01/simpolicy/id_simpolicy.go | 139 ++++ .../2024-04-01/simpolicy/id_simpolicy_test.go | 327 +++++++++ .../method_simpoliciescreateorupdate.go | 75 ++ .../simpolicy/method_simpoliciesdelete.go | 71 ++ .../simpolicy/method_simpoliciesget.go | 54 ++ .../simpolicy/method_simpoliciesupdatetags.go | 58 ++ .../2024-04-01/simpolicy/model_ambr.go | 9 + .../model_datanetworkconfiguration.go | 17 + .../simpolicy/model_datanetworkresourceid.go | 8 + .../simpolicy/model_serviceresourceid.go | 8 + .../2024-04-01/simpolicy/model_simpolicy.go | 18 + .../model_simpolicypropertiesformat.go | 14 + .../simpolicy/model_sliceconfiguration.go | 10 + .../simpolicy/model_sliceresourceid.go | 8 + .../2024-04-01/simpolicy/model_tagsobject.go | 8 + .../2024-04-01/simpolicy/version.go | 12 + .../mobilenetwork/2024-04-01/sims/README.md | 122 ++++ .../mobilenetwork/2024-04-01/sims/client.go | 26 + .../2024-04-01/sims/constants.go | 163 +++++ .../2024-04-01/sims/id_simgroup.go | 130 ++++ .../2024-04-01/sims/id_simgroup_test.go | 282 ++++++++ .../2024-04-01/sims/method_bulkdelete.go | 76 ++ .../2024-04-01/sims/method_bulkupload.go | 75 ++ .../sims/method_bulkuploadencrypted.go | 75 ++ .../2024-04-01/sims/method_clone.go | 75 ++ .../2024-04-01/sims/method_listbygroup.go | 91 +++ .../2024-04-01/sims/method_move.go | 75 ++ .../sims/model_asyncoperationstatus.go | 46 ++ .../model_attacheddatanetworkresourceid.go | 8 + .../model_encryptedsimpropertiesformat.go | 18 + .../sims/model_encryptedsimuploadlist.go | 13 + .../sims/model_erroradditionalinfo.go | 9 + .../2024-04-01/sims/model_errordetail.go | 12 + .../2024-04-01/sims/model_sim.go | 16 + .../2024-04-01/sims/model_simclone.go | 9 + .../2024-04-01/sims/model_simdeletelist.go | 8 + .../sims/model_simgroupresourceid.go | 8 + .../2024-04-01/sims/model_simmove.go | 9 + .../model_simnameandencryptedproperties.go | 9 + .../sims/model_simnameandproperties.go | 9 + .../sims/model_simpolicyresourceid.go | 8 + .../sims/model_simpropertiesformat.go | 19 + .../sims/model_simstaticipproperties.go | 10 + .../model_simstaticippropertiesstaticip.go | 8 + .../2024-04-01/sims/model_simuploadlist.go | 8 + .../2024-04-01/sims/model_sliceresourceid.go | 8 + .../2024-04-01/sims/predicates.go | 27 + .../mobilenetwork/2024-04-01/sims/version.go | 12 + .../mobilenetwork/2024-04-01/site/README.md | 103 +++ .../mobilenetwork/2024-04-01/site/client.go | 26 + .../2024-04-01/site/constants.go | 66 ++ .../mobilenetwork/2024-04-01/site/id_site.go | 139 ++++ .../2024-04-01/site/id_site_test.go | 327 +++++++++ .../2024-04-01/site/method_createorupdate.go | 75 ++ .../2024-04-01/site/method_delete.go | 71 ++ .../site/method_deletepacketcore.go | 74 ++ .../2024-04-01/site/method_get.go | 54 ++ .../2024-04-01/site/method_updatetags.go | 58 ++ .../model_packetcorecontrolplaneresourceid.go | 8 + .../2024-04-01/site/model_site.go | 18 + .../site/model_sitedeletepacketcore.go | 8 + .../site/model_sitepropertiesformat.go | 9 + .../2024-04-01/site/model_subresource.go | 8 + .../2024-04-01/site/model_tagsobject.go | 8 + .../mobilenetwork/2024-04-01/site/version.go | 12 + .../mobilenetwork/2024-04-01/sites/README.md | 37 + .../mobilenetwork/2024-04-01/sites/client.go | 26 + .../2024-04-01/sites/constants.go | 66 ++ .../2024-04-01/sites/id_mobilenetwork.go | 130 ++++ .../2024-04-01/sites/id_mobilenetwork_test.go | 282 ++++++++ .../sites/method_listbymobilenetwork.go | 91 +++ .../2024-04-01/sites/model_site.go | 18 + .../sites/model_sitepropertiesformat.go | 9 + .../2024-04-01/sites/model_subresource.go | 8 + .../2024-04-01/sites/predicates.go | 32 + .../mobilenetwork/2024-04-01/sites/version.go | 12 + .../mobilenetwork/2024-04-01/slice/README.md | 86 +++ .../mobilenetwork/2024-04-01/slice/client.go | 26 + .../2024-04-01/slice/constants.go | 66 ++ .../2024-04-01/slice/id_slice.go | 139 ++++ .../2024-04-01/slice/id_slice_test.go | 327 +++++++++ .../2024-04-01/slice/method_createorupdate.go | 75 ++ .../2024-04-01/slice/method_delete.go | 71 ++ .../2024-04-01/slice/method_get.go | 54 ++ .../2024-04-01/slice/method_updatetags.go | 58 ++ .../2024-04-01/slice/model_slice.go | 18 + .../slice/model_slicepropertiesformat.go | 10 + .../2024-04-01/slice/model_snssai.go | 9 + .../2024-04-01/slice/model_tagsobject.go | 8 + .../mobilenetwork/2024-04-01/slice/version.go | 12 + .../mobilenetwork/2024-04-01/slices/README.md | 37 + .../mobilenetwork/2024-04-01/slices/client.go | 26 + .../2024-04-01/slices/constants.go | 66 ++ .../2024-04-01/slices/id_mobilenetwork.go | 130 ++++ .../slices/id_mobilenetwork_test.go | 282 ++++++++ .../slices/method_listbymobilenetwork.go | 91 +++ .../2024-04-01/slices/model_slice.go | 18 + .../slices/model_slicepropertiesformat.go | 10 + .../2024-04-01/slices/model_snssai.go | 9 + .../2024-04-01/slices/predicates.go | 32 + .../2024-04-01/slices/version.go | 12 + .../2024-04-01/ueinformationlist/README.md | 37 + .../2024-04-01/ueinformationlist/client.go | 26 + .../2024-04-01/ueinformationlist/constants.go | 101 +++ .../id_packetcorecontrolplane.go | 130 ++++ .../id_packetcorecontrolplane_test.go | 282 ++++++++ .../method_ueinformationlist.go | 91 +++ .../ueinformationlist/model_dnnippair.go | 9 + .../ueinformationlist/model_ueinfo.go | 16 + .../model_ueinfopropertiesformat.go | 29 + .../ueinformationlist/model_ueipaddress.go | 8 + .../ueinformationlist/predicates.go | 27 + .../2024-04-01/ueinformationlist/version.go | 12 + 637 files changed, 40246 insertions(+) create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/README.md create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/client.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/constants.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/id_accessconnector.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/id_accessconnector_test.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/method_createorupdate.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/method_delete.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/method_get.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/method_listbyresourcegroup.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/method_listbysubscription.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/method_update.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/model_accessconnector.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/model_accessconnectorproperties.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/model_accessconnectorupdate.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/predicates.go create mode 100644 resource-manager/databricks/2024-05-01/accessconnector/version.go create mode 100644 resource-manager/databricks/2024-05-01/client.go create mode 100644 resource-manager/databricks/2024-05-01/delete/client.go create mode 100644 resource-manager/databricks/2024-05-01/delete/id_privateendpointconnection.go create mode 100644 resource-manager/databricks/2024-05-01/delete/id_privateendpointconnection_test.go create mode 100644 resource-manager/databricks/2024-05-01/delete/method_privateendpointconnectionsdelete.go create mode 100644 resource-manager/databricks/2024-05-01/delete/version.go create mode 100644 resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/README.md create mode 100644 resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/client.go create mode 100644 resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/id_workspace.go create mode 100644 resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/id_workspace_test.go create mode 100644 resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/method_list.go create mode 100644 resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_endpointdependency.go create mode 100644 resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_endpointdetail.go create mode 100644 resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_outboundenvironmentendpoint.go create mode 100644 resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/version.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/README.md create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/client.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/constants.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/id_privateendpointconnection.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/id_privateendpointconnection_test.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/id_workspace.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/id_workspace_test.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/method_create.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/method_delete.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/method_get.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/method_list.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpoint.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpointconnection.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/predicates.go create mode 100644 resource-manager/databricks/2024-05-01/privateendpointconnections/version.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/README.md create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/client.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/id_privatelinkresource.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/id_privatelinkresource_test.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/id_workspace.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/id_workspace_test.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/method_get.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/method_list.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/model_groupidinformation.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/model_groupidinformationproperties.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/predicates.go create mode 100644 resource-manager/databricks/2024-05-01/privatelinkresources/version.go create mode 100644 resource-manager/databricks/2024-05-01/put/README.md create mode 100644 resource-manager/databricks/2024-05-01/put/client.go create mode 100644 resource-manager/databricks/2024-05-01/put/constants.go create mode 100644 resource-manager/databricks/2024-05-01/put/id_privateendpointconnection.go create mode 100644 resource-manager/databricks/2024-05-01/put/id_privateendpointconnection_test.go create mode 100644 resource-manager/databricks/2024-05-01/put/method_privateendpointconnectionscreate.go create mode 100644 resource-manager/databricks/2024-05-01/put/model_privateendpoint.go create mode 100644 resource-manager/databricks/2024-05-01/put/model_privateendpointconnection.go create mode 100644 resource-manager/databricks/2024-05-01/put/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/databricks/2024-05-01/put/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/databricks/2024-05-01/put/version.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/README.md create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/client.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/constants.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/id_virtualnetworkpeering.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/id_virtualnetworkpeering_test.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/id_workspace.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/id_workspace_test.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/method_createorupdate.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/method_delete.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/method_get.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/method_listbyworkspace.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/model_addressspace.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeering.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformat.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformatdatabricksvirtualnetwork.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformatremotevirtualnetwork.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/predicates.go create mode 100644 resource-manager/databricks/2024-05-01/vnetpeering/version.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/README.md create mode 100644 resource-manager/databricks/2024-05-01/workspaces/client.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/constants.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/id_workspace.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/id_workspace_test.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/method_createorupdate.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/method_delete.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/method_get.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/method_listbyresourcegroup.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/method_listbysubscription.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/method_update.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_automaticclusterupdatedefinition.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_compliancesecurityprofiledefinition.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_createdby.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_defaultcatalogproperties.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_encryption.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_encryptionentitiesdefinition.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_encryptionv2.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_encryptionv2keyvaultproperties.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_enhancedsecuritycompliancedefinition.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_enhancedsecuritymonitoringdefinition.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_manageddiskencryption.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_manageddiskencryptionkeyvaultproperties.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_managedidentityconfiguration.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_privateendpoint.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_privateendpointconnection.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_privateendpointconnectionproperties.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_sku.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspace.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspacecustombooleanparameter.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomobjectparameter.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomparameters.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomstringparameter.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspaceencryptionparameter.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspacenopublicipbooleanparameter.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspaceproperties.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspacepropertiesaccessconnector.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspacepropertiesencryption.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspaceproviderauthorization.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/model_workspaceupdate.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/predicates.go create mode 100644 resource-manager/databricks/2024-05-01/workspaces/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/id_attacheddatanetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/id_attacheddatanetwork_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_updatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_attacheddatanetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_attacheddatanetworkpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_interfaceproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_naptconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_pinholetimeouts.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_portrange.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_portreuseholdtimes.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_tagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/id_packetcoredataplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/id_packetcoredataplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/method_listbypacketcoredataplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_attacheddatanetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_attacheddatanetworkpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_interfaceproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_naptconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_pinholetimeouts.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_portrange.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_portreuseholdtimes.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/id_datanetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/id_datanetwork_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/method_updatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/model_datanetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/model_datanetworkpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/model_tagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetwork/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/id_mobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/id_mobilenetwork_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/method_listbymobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/model_datanetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/model_datanetworkpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/datanetworks/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_diagnosticspackage.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_diagnosticspackage_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_packetcorecontrolplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_listbypacketcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/model_diagnosticspackage.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/model_diagnosticspackagepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/id_ue.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/id_ue_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ambr.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_amfid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_extendedueinfo.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_extendedueinfoproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_globalrannodeid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_gnbid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_guti4g.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_guti5g.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_mmeid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_plmnid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_snssai.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueconnectioninfo4g.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueconnectioninfo5g.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo4g.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo4gproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo5g.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo5gproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueipaddress.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uelocationinfo.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueqosflow.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uesessioninfo4g.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uesessioninfo5g.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/extendedueinformation/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/id_mobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/id_mobilenetwork_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_updatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_homenetworkpublickey.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_identityandtagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_mobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_mobilenetworkpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_plmnid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_publiclandmobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_publiclandmobilenetworkhomenetworkpublickeys.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetwork/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/id_mobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/id_mobilenetwork_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listbyresourcegroup.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listbysubscription.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listsimgroups.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_homenetworkpublickey.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_keyvaultkey.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetworkpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetworkresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_plmnid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_publiclandmobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_publiclandmobilenetworkhomenetworkpublickeys.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_simgroup.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_simgrouppropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/mobilenetworks/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcapture.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcapture_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcorecontrolplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_listbypacketcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_stop.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_asyncoperationstatus.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_erroradditionalinfo.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_errordetail.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_packetcapture.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_packetcapturepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcaptures/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/id_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/id_packetcorecontrolplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_updatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_asyncoperationid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_azurestackedgedeviceresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_azurestackhciclusterresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_certificateprovisioning.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_connectedclusterresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_customlocationresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_diagnosticsuploadconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_eventhubconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_homenetworkprivatekeysprovisioning.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_httpsservercertificate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_identityandtagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_installation.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_interfaceproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_localdiagnosticsaccessconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_nasrerouteconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_packetcorecontrolplanepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_platformconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_signalingconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_siteresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_userconsentconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/id_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/id_packetcorecontrolplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/method_packetcorecontrolplanescollectdiagnosticspackage.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_asyncoperationstatus.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_erroradditionalinfo.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_errordetail.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_packetcorecontrolplanecollectdiagnosticspackage.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/id_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/id_packetcorecontrolplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/method_packetcorecontrolplanesreinstall.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_asyncoperationstatus.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_erroradditionalinfo.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_errordetail.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/id_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/id_packetcorecontrolplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/method_packetcorecontrolplanesrollback.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_asyncoperationstatus.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_erroradditionalinfo.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_errordetail.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/method_listbyresourcegroup.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/method_listbysubscription.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_asyncoperationid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_azurestackedgedeviceresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_azurestackhciclusterresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_certificateprovisioning.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_connectedclusterresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_customlocationresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_diagnosticsuploadconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_eventhubconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_homenetworkprivatekeysprovisioning.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_httpsservercertificate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_installation.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_interfaceproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_localdiagnosticsaccessconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_nasrerouteconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_packetcorecontrolplanepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_platformconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_signalingconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_siteresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_userconsentconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_packetcorecontrolplaneversion.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_packetcorecontrolplaneversion_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_providerpacketcorecontrolplaneversion.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_providerpacketcorecontrolplaneversion_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_getbysubscription.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_list.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_listbysubscription.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_packetcorecontrolplaneversion.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_packetcorecontrolplaneversionpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_platform.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/id_packetcoredataplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/id_packetcoredataplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_updatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_interfaceproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_packetcoredataplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_packetcoredataplanepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_tagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/id_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/id_packetcorecontrolplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/method_listbypacketcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_interfaceproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_packetcoredataplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_packetcoredataplanepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/id_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/id_packetcorecontrolplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/method_list.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/model_attacheddatanetworkresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/model_ipv4route.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/model_ipv4routenexthop.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/model_routinginfomodel.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/model_routinginfopropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/model_userplanedataroutesuserplanedataroutesinlined.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/routinginfo/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/id_service.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/id_service_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/method_updatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/model_ambr.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/model_pccruleconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/model_pccruleqospolicy.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/model_qospolicy.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/model_service.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/model_servicedataflowtemplate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/model_servicepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/model_tagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/service/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/id_mobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/id_mobilenetwork_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/method_listbymobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/model_ambr.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/model_pccruleconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/model_pccruleqospolicy.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/model_qospolicy.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/model_service.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/model_servicedataflowtemplate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/model_servicepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/services/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/id_sim.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/id_sim_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/model_attacheddatanetworkresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/model_sim.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/model_simpolicyresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/model_simpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/model_simstaticipproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/model_simstaticippropertiesstaticip.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/model_sliceresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sim/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/id_simgroup.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/id_simgroup_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/method_updatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/model_identityandtagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/model_keyvaultkey.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/model_mobilenetworkresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/model_simgroup.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/model_simgrouppropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroup/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/method_listbyresourcegroup.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/method_listbysubscription.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/model_keyvaultkey.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/model_mobilenetworkresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/model_simgroup.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/model_simgrouppropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simgroups/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/id_mobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/id_mobilenetwork_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/method_listbymobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/model_ambr.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/model_datanetworkconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/model_datanetworkresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/model_serviceresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/model_simpolicy.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/model_simpolicypropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/model_sliceconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/model_sliceresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicies/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/id_simpolicy.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/id_simpolicy_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciescreateorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesdelete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesget.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesupdatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/model_ambr.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/model_datanetworkconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/model_datanetworkresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/model_serviceresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/model_simpolicy.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/model_simpolicypropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/model_sliceconfiguration.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/model_sliceresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/model_tagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/simpolicy/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/id_simgroup.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/id_simgroup_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/method_bulkdelete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/method_bulkupload.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/method_bulkuploadencrypted.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/method_clone.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/method_listbygroup.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/method_move.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_asyncoperationstatus.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_attacheddatanetworkresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_encryptedsimpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_encryptedsimuploadlist.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_erroradditionalinfo.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_errordetail.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_sim.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simclone.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simdeletelist.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simgroupresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simmove.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simnameandencryptedproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simnameandproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simpolicyresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simpropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simstaticipproperties.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simstaticippropertiesstaticip.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_simuploadlist.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/model_sliceresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sims/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/id_site.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/id_site_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/method_deletepacketcore.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/method_updatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/model_packetcorecontrolplaneresourceid.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/model_site.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/model_sitedeletepacketcore.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/model_sitepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/model_subresource.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/model_tagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/site/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/id_mobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/id_mobilenetwork_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/method_listbymobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/model_site.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/model_sitepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/model_subresource.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/sites/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/id_slice.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/id_slice_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/method_createorupdate.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/method_delete.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/method_get.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/method_updatetags.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/model_slice.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/model_slicepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/model_snssai.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/model_tagsobject.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slice/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/id_mobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/id_mobilenetwork_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/method_listbymobilenetwork.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/model_slice.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/model_slicepropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/model_snssai.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/slices/version.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/README.md create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/client.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/constants.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/id_packetcorecontrolplane.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/id_packetcorecontrolplane_test.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/method_ueinformationlist.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_dnnippair.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueinfo.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueinfopropertiesformat.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueipaddress.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/predicates.go create mode 100644 resource-manager/mobilenetwork/2024-04-01/ueinformationlist/version.go diff --git a/resource-manager/databricks/2024-05-01/accessconnector/README.md b/resource-manager/databricks/2024-05-01/accessconnector/README.md new file mode 100644 index 00000000000..821aeed5adf --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/accessconnector` Documentation + +The `accessconnector` SDK allows for interaction with the Azure Resource Manager Service `databricks` (API Version `2024-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/accessconnector" +``` + + +### Client Initialization + +```go +client := accessconnector.NewAccessConnectorClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AccessConnectorClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := accessconnector.NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accessConnectorValue") + +payload := accessconnector.AccessConnector{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AccessConnectorClient.Delete` + +```go +ctx := context.TODO() +id := accessconnector.NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accessConnectorValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AccessConnectorClient.Get` + +```go +ctx := context.TODO() +id := accessconnector.NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accessConnectorValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AccessConnectorClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AccessConnectorClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AccessConnectorClient.Update` + +```go +ctx := context.TODO() +id := accessconnector.NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accessConnectorValue") + +payload := accessconnector.AccessConnectorUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/databricks/2024-05-01/accessconnector/client.go b/resource-manager/databricks/2024-05-01/accessconnector/client.go new file mode 100644 index 00000000000..934dd952c30 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/client.go @@ -0,0 +1,26 @@ +package accessconnector + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessConnectorClient struct { + Client *resourcemanager.Client +} + +func NewAccessConnectorClientWithBaseURI(sdkApi sdkEnv.Api) (*AccessConnectorClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "accessconnector", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AccessConnectorClient: %+v", err) + } + + return &AccessConnectorClient{ + Client: client, + }, nil +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/constants.go b/resource-manager/databricks/2024-05-01/accessconnector/constants.go new file mode 100644 index 00000000000..388470b9144 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/constants.go @@ -0,0 +1,54 @@ +package accessconnector + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleted), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleted": ProvisioningStateDeleted, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/id_accessconnector.go b/resource-manager/databricks/2024-05-01/accessconnector/id_accessconnector.go new file mode 100644 index 00000000000..7945a8c422b --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/id_accessconnector.go @@ -0,0 +1,130 @@ +package accessconnector + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AccessConnectorId{}) +} + +var _ resourceids.ResourceId = &AccessConnectorId{} + +// AccessConnectorId is a struct representing the Resource ID for a Access Connector +type AccessConnectorId struct { + SubscriptionId string + ResourceGroupName string + AccessConnectorName string +} + +// NewAccessConnectorID returns a new AccessConnectorId struct +func NewAccessConnectorID(subscriptionId string, resourceGroupName string, accessConnectorName string) AccessConnectorId { + return AccessConnectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccessConnectorName: accessConnectorName, + } +} + +// ParseAccessConnectorID parses 'input' into a AccessConnectorId +func ParseAccessConnectorID(input string) (*AccessConnectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccessConnectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccessConnectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAccessConnectorIDInsensitively parses 'input' case-insensitively into a AccessConnectorId +// note: this method should only be used for API response data and not user input +func ParseAccessConnectorIDInsensitively(input string) (*AccessConnectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccessConnectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccessConnectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AccessConnectorId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccessConnectorName, ok = input.Parsed["accessConnectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accessConnectorName", input) + } + + return nil +} + +// ValidateAccessConnectorID checks that 'input' can be parsed as a Access Connector ID +func ValidateAccessConnectorID(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 := ParseAccessConnectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Access Connector ID +func (id AccessConnectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Databricks/accessConnectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccessConnectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Access Connector ID +func (id AccessConnectorId) 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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + resourceids.StaticSegment("staticAccessConnectors", "accessConnectors", "accessConnectors"), + resourceids.UserSpecifiedSegment("accessConnectorName", "accessConnectorValue"), + } +} + +// String returns a human-readable description of this Access Connector ID +func (id AccessConnectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Access Connector Name: %q", id.AccessConnectorName), + } + return fmt.Sprintf("Access Connector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/id_accessconnector_test.go b/resource-manager/databricks/2024-05-01/accessconnector/id_accessconnector_test.go new file mode 100644 index 00000000000..546f73b89c7 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/id_accessconnector_test.go @@ -0,0 +1,282 @@ +package accessconnector + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AccessConnectorId{} + +func TestNewAccessConnectorID(t *testing.T) { + id := NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accessConnectorValue") + + 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.AccessConnectorName != "accessConnectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'AccessConnectorName'", id.AccessConnectorName, "accessConnectorValue") + } +} + +func TestFormatAccessConnectorID(t *testing.T) { + actual := NewAccessConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accessConnectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/accessConnectors/accessConnectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAccessConnectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccessConnectorId + }{ + { + // 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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/accessConnectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/accessConnectors/accessConnectorValue", + Expected: &AccessConnectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AccessConnectorName: "accessConnectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/accessConnectors/accessConnectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccessConnectorID(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.AccessConnectorName != v.Expected.AccessConnectorName { + t.Fatalf("Expected %q but got %q for AccessConnectorName", v.Expected.AccessConnectorName, actual.AccessConnectorName) + } + + } +} + +func TestParseAccessConnectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccessConnectorId + }{ + { + // 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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/accessConnectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/aCcEsScOnNeCtOrS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/accessConnectors/accessConnectorValue", + Expected: &AccessConnectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AccessConnectorName: "accessConnectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/accessConnectors/accessConnectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/aCcEsScOnNeCtOrS/aCcEsScOnNeCtOrVaLuE", + Expected: &AccessConnectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AccessConnectorName: "aCcEsScOnNeCtOrVaLuE", + }, + }, + { + // 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.dAtAbRiCkS/aCcEsScOnNeCtOrS/aCcEsScOnNeCtOrVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccessConnectorIDInsensitively(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.AccessConnectorName != v.Expected.AccessConnectorName { + t.Fatalf("Expected %q but got %q for AccessConnectorName", v.Expected.AccessConnectorName, actual.AccessConnectorName) + } + + } +} + +func TestSegmentsForAccessConnectorId(t *testing.T) { + segments := AccessConnectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AccessConnectorId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/method_createorupdate.go b/resource-manager/databricks/2024-05-01/accessconnector/method_createorupdate.go new file mode 100644 index 00000000000..d647fe67948 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/method_createorupdate.go @@ -0,0 +1,75 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AccessConnector +} + +// CreateOrUpdate ... +func (c AccessConnectorClient) CreateOrUpdate(ctx context.Context, id AccessConnectorId, input AccessConnector) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AccessConnectorClient) CreateOrUpdateThenPoll(ctx context.Context, id AccessConnectorId, input AccessConnector) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/method_delete.go b/resource-manager/databricks/2024-05-01/accessconnector/method_delete.go new file mode 100644 index 00000000000..3a9ab55cbb4 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/method_delete.go @@ -0,0 +1,71 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AccessConnectorClient) Delete(ctx context.Context, id AccessConnectorId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AccessConnectorClient) DeleteThenPoll(ctx context.Context, id AccessConnectorId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/method_get.go b/resource-manager/databricks/2024-05-01/accessconnector/method_get.go new file mode 100644 index 00000000000..b35134f9e29 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/method_get.go @@ -0,0 +1,54 @@ +package accessconnector + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessConnector +} + +// Get ... +func (c AccessConnectorClient) Get(ctx context.Context, id AccessConnectorId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AccessConnector + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/method_listbyresourcegroup.go b/resource-manager/databricks/2024-05-01/accessconnector/method_listbyresourcegroup.go new file mode 100644 index 00000000000..55501808230 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AccessConnector +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AccessConnector +} + +// ListByResourceGroup ... +func (c AccessConnectorClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Databricks/accessConnectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AccessConnector `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AccessConnectorClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AccessConnectorOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AccessConnectorClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccessConnectorOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AccessConnector, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/method_listbysubscription.go b/resource-manager/databricks/2024-05-01/accessconnector/method_listbysubscription.go new file mode 100644 index 00000000000..a91c263116a --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/method_listbysubscription.go @@ -0,0 +1,92 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AccessConnector +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []AccessConnector +} + +// ListBySubscription ... +func (c AccessConnectorClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Databricks/accessConnectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AccessConnector `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AccessConnectorClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AccessConnectorOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AccessConnectorClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccessConnectorOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]AccessConnector, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/method_update.go b/resource-manager/databricks/2024-05-01/accessconnector/method_update.go new file mode 100644 index 00000000000..da352c23cef --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/method_update.go @@ -0,0 +1,75 @@ +package accessconnector + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AccessConnector +} + +// Update ... +func (c AccessConnectorClient) Update(ctx context.Context, id AccessConnectorId, input AccessConnectorUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c AccessConnectorClient) UpdateThenPoll(ctx context.Context, id AccessConnectorId, input AccessConnectorUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/model_accessconnector.go b/resource-manager/databricks/2024-05-01/accessconnector/model_accessconnector.go new file mode 100644 index 00000000000..240dac9a90a --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/model_accessconnector.go @@ -0,0 +1,20 @@ +package accessconnector + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessConnector struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AccessConnectorProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/model_accessconnectorproperties.go b/resource-manager/databricks/2024-05-01/accessconnector/model_accessconnectorproperties.go new file mode 100644 index 00000000000..8078e3e644f --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/model_accessconnectorproperties.go @@ -0,0 +1,9 @@ +package accessconnector + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessConnectorProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ReferedBy *[]string `json:"referedBy,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/model_accessconnectorupdate.go b/resource-manager/databricks/2024-05-01/accessconnector/model_accessconnectorupdate.go new file mode 100644 index 00000000000..68344d3a48c --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/model_accessconnectorupdate.go @@ -0,0 +1,13 @@ +package accessconnector + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessConnectorUpdate struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/predicates.go b/resource-manager/databricks/2024-05-01/accessconnector/predicates.go new file mode 100644 index 00000000000..4d1f4082039 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/predicates.go @@ -0,0 +1,32 @@ +package accessconnector + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessConnectorOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AccessConnectorOperationPredicate) Matches(input AccessConnector) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/databricks/2024-05-01/accessconnector/version.go b/resource-manager/databricks/2024-05-01/accessconnector/version.go new file mode 100644 index 00000000000..fcc706808f4 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/accessconnector/version.go @@ -0,0 +1,12 @@ +package accessconnector + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/accessconnector/%s", defaultApiVersion) +} diff --git a/resource-manager/databricks/2024-05-01/client.go b/resource-manager/databricks/2024-05-01/client.go new file mode 100644 index 00000000000..251da780947 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/client.go @@ -0,0 +1,91 @@ +package v2024_05_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/accessconnector" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/delete" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/privateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/put" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/vnetpeering" + "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/workspaces" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AccessConnector *accessconnector.AccessConnectorClient + DELETE *delete.DELETEClient + OutboundNetworkDependenciesEndpoints *outboundnetworkdependenciesendpoints.OutboundNetworkDependenciesEndpointsClient + PUT *put.PUTClient + PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient + PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient + VNetPeering *vnetpeering.VNetPeeringClient + Workspaces *workspaces.WorkspacesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + accessConnectorClient, err := accessconnector.NewAccessConnectorClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AccessConnector client: %+v", err) + } + configureFunc(accessConnectorClient.Client) + + dELETEClient, err := delete.NewDELETEClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DELETE client: %+v", err) + } + configureFunc(dELETEClient.Client) + + outboundNetworkDependenciesEndpointsClient, err := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building OutboundNetworkDependenciesEndpoints client: %+v", err) + } + configureFunc(outboundNetworkDependenciesEndpointsClient.Client) + + pUTClient, err := put.NewPUTClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PUT client: %+v", err) + } + configureFunc(pUTClient.Client) + + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) + + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) + } + configureFunc(privateLinkResourcesClient.Client) + + vNetPeeringClient, err := vnetpeering.NewVNetPeeringClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VNetPeering client: %+v", err) + } + configureFunc(vNetPeeringClient.Client) + + workspacesClient, err := workspaces.NewWorkspacesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Workspaces client: %+v", err) + } + configureFunc(workspacesClient.Client) + + return &Client{ + AccessConnector: accessConnectorClient, + DELETE: dELETEClient, + OutboundNetworkDependenciesEndpoints: outboundNetworkDependenciesEndpointsClient, + PUT: pUTClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + VNetPeering: vNetPeeringClient, + Workspaces: workspacesClient, + }, nil +} diff --git a/resource-manager/databricks/2024-05-01/delete/client.go b/resource-manager/databricks/2024-05-01/delete/client.go new file mode 100644 index 00000000000..f7a3ebd1edb --- /dev/null +++ b/resource-manager/databricks/2024-05-01/delete/client.go @@ -0,0 +1,26 @@ +package delete + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DELETEClient struct { + Client *resourcemanager.Client +} + +func NewDELETEClientWithBaseURI(sdkApi sdkEnv.Api) (*DELETEClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "delete", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DELETEClient: %+v", err) + } + + return &DELETEClient{ + Client: client, + }, nil +} diff --git a/resource-manager/databricks/2024-05-01/delete/id_privateendpointconnection.go b/resource-manager/databricks/2024-05-01/delete/id_privateendpointconnection.go new file mode 100644 index 00000000000..61ac031cf2f --- /dev/null +++ b/resource-manager/databricks/2024-05-01/delete/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package delete + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, workspaceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Databricks/workspaces/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, 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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + 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("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/databricks/2024-05-01/delete/id_privateendpointconnection_test.go b/resource-manager/databricks/2024-05-01/delete/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..8d24df7f793 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/delete/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package delete + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "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.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } + + 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", "workspaceValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + 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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + 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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/databricks/2024-05-01/delete/method_privateendpointconnectionsdelete.go b/resource-manager/databricks/2024-05-01/delete/method_privateendpointconnectionsdelete.go new file mode 100644 index 00000000000..06e5dcfc4b2 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/delete/method_privateendpointconnectionsdelete.go @@ -0,0 +1,71 @@ +package delete + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionsDelete ... +func (c DELETEClient) PrivateEndpointConnectionsDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PrivateEndpointConnectionsDeleteThenPoll performs PrivateEndpointConnectionsDelete then polls until it's completed +func (c DELETEClient) PrivateEndpointConnectionsDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.PrivateEndpointConnectionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/delete/version.go b/resource-manager/databricks/2024-05-01/delete/version.go new file mode 100644 index 00000000000..6b1e42af68a --- /dev/null +++ b/resource-manager/databricks/2024-05-01/delete/version.go @@ -0,0 +1,12 @@ +package delete + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/delete/%s", defaultApiVersion) +} diff --git a/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/README.md b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/README.md new file mode 100644 index 00000000000..8a20eba4e7a --- /dev/null +++ b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints` Documentation + +The `outboundnetworkdependenciesendpoints` SDK allows for interaction with the Azure Resource Manager Service `databricks` (API Version `2024-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints" +``` + + +### Client Initialization + +```go +client := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OutboundNetworkDependenciesEndpointsClient.List` + +```go +ctx := context.TODO() +id := outboundnetworkdependenciesendpoints.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/client.go b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/client.go new file mode 100644 index 00000000000..d5ab391daa6 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/client.go @@ -0,0 +1,26 @@ +package outboundnetworkdependenciesendpoints + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundNetworkDependenciesEndpointsClient struct { + Client *resourcemanager.Client +} + +func NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(sdkApi sdkEnv.Api) (*OutboundNetworkDependenciesEndpointsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "outboundnetworkdependenciesendpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OutboundNetworkDependenciesEndpointsClient: %+v", err) + } + + return &OutboundNetworkDependenciesEndpointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/id_workspace.go b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/id_workspace.go new file mode 100644 index 00000000000..df605774924 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/id_workspace.go @@ -0,0 +1,130 @@ +package outboundnetworkdependenciesendpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return 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.Databricks/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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + 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/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/id_workspace_test.go b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/id_workspace_test.go new file mode 100644 index 00000000000..84e6f029a32 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/id_workspace_test.go @@ -0,0 +1,282 @@ +package outboundnetworkdependenciesendpoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.dAtAbRiCkS/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.dAtAbRiCkS/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/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/method_list.go b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/method_list.go new file mode 100644 index 00000000000..f9dac1d6f6a --- /dev/null +++ b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/method_list.go @@ -0,0 +1,55 @@ +package outboundnetworkdependenciesendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +// List ... +func (c OutboundNetworkDependenciesEndpointsClient) List(ctx context.Context, id WorkspaceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []OutboundEnvironmentEndpoint + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_endpointdependency.go b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_endpointdependency.go new file mode 100644 index 00000000000..81feeb21f76 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_endpointdependency.go @@ -0,0 +1,9 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDependency struct { + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]EndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_endpointdetail.go b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_endpointdetail.go new file mode 100644 index 00000000000..73ae63ea3b9 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_endpointdetail.go @@ -0,0 +1,11 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDetail struct { + IPAddress *string `json:"ipAddress,omitempty"` + IsAccessible *bool `json:"isAccessible,omitempty"` + Latency *float64 `json:"latency,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_outboundenvironmentendpoint.go b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_outboundenvironmentendpoint.go new file mode 100644 index 00000000000..d481f55194e --- /dev/null +++ b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/model_outboundenvironmentendpoint.go @@ -0,0 +1,9 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundEnvironmentEndpoint struct { + Category *string `json:"category,omitempty"` + Endpoints *[]EndpointDependency `json:"endpoints,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/version.go b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/version.go new file mode 100644 index 00000000000..642b15db3ac --- /dev/null +++ b/resource-manager/databricks/2024-05-01/outboundnetworkdependenciesendpoints/version.go @@ -0,0 +1,12 @@ +package outboundnetworkdependenciesendpoints + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/outboundnetworkdependenciesendpoints/%s", defaultApiVersion) +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/README.md b/resource-manager/databricks/2024-05-01/privateendpointconnections/README.md new file mode 100644 index 00000000000..f8b82cfe60c --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/privateendpointconnections` Documentation + +The `privateendpointconnections` SDK allows for interaction with the Azure Resource Manager Service `databricks` (API Version `2024-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/privateendpointconnections" +``` + + +### Client Initialization + +```go +client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Create` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "privateEndpointConnectionValue") + +payload := privateendpointconnections.PrivateEndpointConnection{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "privateEndpointConnectionValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "privateEndpointConnectionValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.List` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/client.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/client.go new file mode 100644 index 00000000000..3bf7a6afe1f --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/client.go @@ -0,0 +1,26 @@ +package privateendpointconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) + } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/constants.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/constants.go new file mode 100644 index 00000000000..2ee84b1650f --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/constants.go @@ -0,0 +1,107 @@ +package privateendpointconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/id_privateendpointconnection.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 00000000000..9307cc52bd0 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, workspaceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Databricks/workspaces/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, 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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + 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("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..4c4a9baaefd --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "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.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } + + 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", "workspaceValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + 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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + 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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/id_workspace.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/id_workspace.go new file mode 100644 index 00000000000..20bd077f889 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/id_workspace.go @@ -0,0 +1,130 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return 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.Databricks/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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + 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/resource-manager/databricks/2024-05-01/privateendpointconnections/id_workspace_test.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/id_workspace_test.go new file mode 100644 index 00000000000..72725f11392 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/id_workspace_test.go @@ -0,0 +1,282 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.dAtAbRiCkS/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.dAtAbRiCkS/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/resource-manager/databricks/2024-05-01/privateendpointconnections/method_create.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/method_create.go new file mode 100644 index 00000000000..8e4db5501ac --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/method_create.go @@ -0,0 +1,75 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Create ... +func (c PrivateEndpointConnectionsClient) Create(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c PrivateEndpointConnectionsClient) CreateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/method_delete.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..63c26e8f27f --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/method_delete.go @@ -0,0 +1,71 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/method_get.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..8dc28d7ff7a --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/method_get.go @@ -0,0 +1,54 @@ +package privateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/method_list.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/method_list.go new file mode 100644 index 00000000000..2ccb8a8ab19 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/method_list.go @@ -0,0 +1,91 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +// List ... +func (c PrivateEndpointConnectionsClient) List(ctx context.Context, id WorkspaceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PrivateEndpointConnectionsClient) ListComplete(ctx context.Context, id WorkspaceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointConnectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate PrivateEndpointConnectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpoint.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpoint.go new file mode 100644 index 00000000000..1bc8cf2a97c --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpoint.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..a00059f768e --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties PrivateEndpointConnectionProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..fb540c904b6 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..d7ae83ad4d8 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status PrivateLinkServiceConnectionStatus `json:"status"` +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/predicates.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/predicates.go new file mode 100644 index 00000000000..4a03a91ce52 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/predicates.go @@ -0,0 +1,27 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/databricks/2024-05-01/privateendpointconnections/version.go b/resource-manager/databricks/2024-05-01/privateendpointconnections/version.go new file mode 100644 index 00000000000..b541d16e87d --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privateendpointconnections/version.go @@ -0,0 +1,12 @@ +package privateendpointconnections + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/privateendpointconnections/%s", defaultApiVersion) +} diff --git a/resource-manager/databricks/2024-05-01/privatelinkresources/README.md b/resource-manager/databricks/2024-05-01/privatelinkresources/README.md new file mode 100644 index 00000000000..2076df49ac0 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/privatelinkresources` Documentation + +The `privatelinkresources` SDK allows for interaction with the Azure Resource Manager Service `databricks` (API Version `2024-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/privatelinkresources" +``` + + +### Client Initialization + +```go +client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkResourcesClient.Get` + +```go +ctx := context.TODO() +id := privatelinkresources.NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "groupIdValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateLinkResourcesClient.List` + +```go +ctx := context.TODO() +id := privatelinkresources.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/databricks/2024-05-01/privatelinkresources/client.go b/resource-manager/databricks/2024-05-01/privatelinkresources/client.go new file mode 100644 index 00000000000..e6e22caa746 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/client.go @@ -0,0 +1,26 @@ +package privatelinkresources + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) + } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/databricks/2024-05-01/privatelinkresources/id_privatelinkresource.go b/resource-manager/databricks/2024-05-01/privatelinkresources/id_privatelinkresource.go new file mode 100644 index 00000000000..bd946e8a4ea --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/id_privatelinkresource.go @@ -0,0 +1,139 @@ +package privatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &PrivateLinkResourceId{} + +// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource +type PrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + GroupId string +} + +// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct +func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, workspaceName string, groupId string) PrivateLinkResourceId { + return PrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + GroupId: groupId, + } +} + +// 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) + } + + id := PrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := PrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateLinkResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.GroupId, ok = input.Parsed["groupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "groupId", input) + } + + return 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.Databricks/workspaces/%s/privateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.GroupId) +} + +// 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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), + resourceids.UserSpecifiedSegment("groupId", "groupIdValue"), + } +} + +// 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("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Group: %q", id.GroupId), + } + return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/databricks/2024-05-01/privatelinkresources/id_privatelinkresource_test.go b/resource-manager/databricks/2024-05-01/privatelinkresources/id_privatelinkresource_test.go new file mode 100644 index 00000000000..446454b0e9f --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/id_privatelinkresource_test.go @@ -0,0 +1,327 @@ +package privatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateLinkResourceId{} + +func TestNewPrivateLinkResourceID(t *testing.T) { + id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "groupIdValue") + + 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.GroupId != "groupIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'GroupId'", id.GroupId, "groupIdValue") + } +} + +func TestFormatPrivateLinkResourceID(t *testing.T) { + actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "groupIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateLinkResources/groupIdValue" + 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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateLinkResources/groupIdValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + GroupId: "groupIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateLinkResources/groupIdValue/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.GroupId != v.Expected.GroupId { + t.Fatalf("Expected %q but got %q for GroupId", v.Expected.GroupId, actual.GroupId) + } + + } +} + +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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/pRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateLinkResources/groupIdValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + GroupId: "groupIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateLinkResources/groupIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/pRiVaTeLiNkReSoUrCeS/gRoUpIdVaLuE", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + GroupId: "gRoUpIdVaLuE", + }, + }, + { + // 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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/pRiVaTeLiNkReSoUrCeS/gRoUpIdVaLuE/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.GroupId != v.Expected.GroupId { + t.Fatalf("Expected %q but got %q for GroupId", v.Expected.GroupId, actual.GroupId) + } + + } +} + +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/resource-manager/databricks/2024-05-01/privatelinkresources/id_workspace.go b/resource-manager/databricks/2024-05-01/privatelinkresources/id_workspace.go new file mode 100644 index 00000000000..f74868d63e3 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/id_workspace.go @@ -0,0 +1,130 @@ +package privatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return 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.Databricks/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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + 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/resource-manager/databricks/2024-05-01/privatelinkresources/id_workspace_test.go b/resource-manager/databricks/2024-05-01/privatelinkresources/id_workspace_test.go new file mode 100644 index 00000000000..08b3af53849 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/id_workspace_test.go @@ -0,0 +1,282 @@ +package privatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.dAtAbRiCkS/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.dAtAbRiCkS/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/resource-manager/databricks/2024-05-01/privatelinkresources/method_get.go b/resource-manager/databricks/2024-05-01/privatelinkresources/method_get.go new file mode 100644 index 00000000000..e8de18c1783 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/method_get.go @@ -0,0 +1,54 @@ +package privatelinkresources + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GroupIdInformation +} + +// Get ... +func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model GroupIdInformation + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/databricks/2024-05-01/privatelinkresources/method_list.go b/resource-manager/databricks/2024-05-01/privatelinkresources/method_list.go new file mode 100644 index 00000000000..b0c8696222c --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/method_list.go @@ -0,0 +1,91 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GroupIdInformation +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []GroupIdInformation +} + +// List ... +func (c PrivateLinkResourcesClient) List(ctx context.Context, id WorkspaceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GroupIdInformation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PrivateLinkResourcesClient) ListComplete(ctx context.Context, id WorkspaceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, GroupIdInformationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkResourcesClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate GroupIdInformationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]GroupIdInformation, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/databricks/2024-05-01/privatelinkresources/model_groupidinformation.go b/resource-manager/databricks/2024-05-01/privatelinkresources/model_groupidinformation.go new file mode 100644 index 00000000000..c095eca2f2a --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/model_groupidinformation.go @@ -0,0 +1,11 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GroupIdInformation struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties GroupIdInformationProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/privatelinkresources/model_groupidinformationproperties.go b/resource-manager/databricks/2024-05-01/privatelinkresources/model_groupidinformationproperties.go new file mode 100644 index 00000000000..c18b94190af --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/model_groupidinformationproperties.go @@ -0,0 +1,10 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GroupIdInformationProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/privatelinkresources/predicates.go b/resource-manager/databricks/2024-05-01/privatelinkresources/predicates.go new file mode 100644 index 00000000000..16f1098713f --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/predicates.go @@ -0,0 +1,27 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GroupIdInformationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p GroupIdInformationOperationPredicate) Matches(input GroupIdInformation) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/databricks/2024-05-01/privatelinkresources/version.go b/resource-manager/databricks/2024-05-01/privatelinkresources/version.go new file mode 100644 index 00000000000..14d0bb2a379 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/privatelinkresources/version.go @@ -0,0 +1,12 @@ +package privatelinkresources + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/privatelinkresources/%s", defaultApiVersion) +} diff --git a/resource-manager/databricks/2024-05-01/put/README.md b/resource-manager/databricks/2024-05-01/put/README.md new file mode 100644 index 00000000000..98cca7c04b5 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/put` Documentation + +The `put` SDK allows for interaction with the Azure Resource Manager Service `databricks` (API Version `2024-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/put" +``` + + +### Client Initialization + +```go +client := put.NewPUTClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PUTClient.PrivateEndpointConnectionsCreate` + +```go +ctx := context.TODO() +id := put.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "privateEndpointConnectionValue") + +payload := put.PrivateEndpointConnection{ + // ... +} + + +if err := client.PrivateEndpointConnectionsCreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/databricks/2024-05-01/put/client.go b/resource-manager/databricks/2024-05-01/put/client.go new file mode 100644 index 00000000000..6f8700864e0 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/client.go @@ -0,0 +1,26 @@ +package put + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PUTClient struct { + Client *resourcemanager.Client +} + +func NewPUTClientWithBaseURI(sdkApi sdkEnv.Api) (*PUTClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "put", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PUTClient: %+v", err) + } + + return &PUTClient{ + Client: client, + }, nil +} diff --git a/resource-manager/databricks/2024-05-01/put/constants.go b/resource-manager/databricks/2024-05-01/put/constants.go new file mode 100644 index 00000000000..8e62f1de14b --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/constants.go @@ -0,0 +1,107 @@ +package put + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/databricks/2024-05-01/put/id_privateendpointconnection.go b/resource-manager/databricks/2024-05-01/put/id_privateendpointconnection.go new file mode 100644 index 00000000000..808bfd0f9af --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package put + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, workspaceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Databricks/workspaces/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, 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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + 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("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/databricks/2024-05-01/put/id_privateendpointconnection_test.go b/resource-manager/databricks/2024-05-01/put/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..6cc60fba8eb --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package put + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "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.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } + + 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", "workspaceValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + 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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + 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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/databricks/2024-05-01/put/method_privateendpointconnectionscreate.go b/resource-manager/databricks/2024-05-01/put/method_privateendpointconnectionscreate.go new file mode 100644 index 00000000000..90ec8cc9734 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/method_privateendpointconnectionscreate.go @@ -0,0 +1,75 @@ +package put + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsCreate ... +func (c PUTClient) PrivateEndpointConnectionsCreate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PrivateEndpointConnectionsCreateThenPoll performs PrivateEndpointConnectionsCreate then polls until it's completed +func (c PUTClient) PrivateEndpointConnectionsCreateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { + result, err := c.PrivateEndpointConnectionsCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionsCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionsCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/put/model_privateendpoint.go b/resource-manager/databricks/2024-05-01/put/model_privateendpoint.go new file mode 100644 index 00000000000..9debd27fc1a --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/model_privateendpoint.go @@ -0,0 +1,8 @@ +package put + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/put/model_privateendpointconnection.go b/resource-manager/databricks/2024-05-01/put/model_privateendpointconnection.go new file mode 100644 index 00000000000..3c18d762a91 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package put + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties PrivateEndpointConnectionProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/put/model_privateendpointconnectionproperties.go b/resource-manager/databricks/2024-05-01/put/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..a3aa6bead7c --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package put + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/put/model_privatelinkserviceconnectionstate.go b/resource-manager/databricks/2024-05-01/put/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..ecc66b980fb --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package put + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status PrivateLinkServiceConnectionStatus `json:"status"` +} diff --git a/resource-manager/databricks/2024-05-01/put/version.go b/resource-manager/databricks/2024-05-01/put/version.go new file mode 100644 index 00000000000..d853a9d353b --- /dev/null +++ b/resource-manager/databricks/2024-05-01/put/version.go @@ -0,0 +1,12 @@ +package put + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/put/%s", defaultApiVersion) +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/README.md b/resource-manager/databricks/2024-05-01/vnetpeering/README.md new file mode 100644 index 00000000000..65527a7b990 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/vnetpeering` Documentation + +The `vnetpeering` SDK allows for interaction with the Azure Resource Manager Service `databricks` (API Version `2024-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/vnetpeering" +``` + + +### Client Initialization + +```go +client := vnetpeering.NewVNetPeeringClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VNetPeeringClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := vnetpeering.NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "virtualNetworkPeeringValue") + +payload := vnetpeering.VirtualNetworkPeering{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VNetPeeringClient.Delete` + +```go +ctx := context.TODO() +id := vnetpeering.NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "virtualNetworkPeeringValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VNetPeeringClient.Get` + +```go +ctx := context.TODO() +id := vnetpeering.NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "virtualNetworkPeeringValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VNetPeeringClient.ListByWorkspace` + +```go +ctx := context.TODO() +id := vnetpeering.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +// alternatively `client.ListByWorkspace(ctx, id)` can be used to do batched pagination +items, err := client.ListByWorkspaceComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/client.go b/resource-manager/databricks/2024-05-01/vnetpeering/client.go new file mode 100644 index 00000000000..32828af1493 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/client.go @@ -0,0 +1,26 @@ +package vnetpeering + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VNetPeeringClient struct { + Client *resourcemanager.Client +} + +func NewVNetPeeringClientWithBaseURI(sdkApi sdkEnv.Api) (*VNetPeeringClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "vnetpeering", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VNetPeeringClient: %+v", err) + } + + return &VNetPeeringClient{ + Client: client, + }, nil +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/constants.go b/resource-manager/databricks/2024-05-01/vnetpeering/constants.go new file mode 100644 index 00000000000..f8ec6f58c22 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/constants.go @@ -0,0 +1,101 @@ +package vnetpeering + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeeringProvisioningState string + +const ( + PeeringProvisioningStateDeleting PeeringProvisioningState = "Deleting" + PeeringProvisioningStateFailed PeeringProvisioningState = "Failed" + PeeringProvisioningStateSucceeded PeeringProvisioningState = "Succeeded" + PeeringProvisioningStateUpdating PeeringProvisioningState = "Updating" +) + +func PossibleValuesForPeeringProvisioningState() []string { + return []string{ + string(PeeringProvisioningStateDeleting), + string(PeeringProvisioningStateFailed), + string(PeeringProvisioningStateSucceeded), + string(PeeringProvisioningStateUpdating), + } +} + +func (s *PeeringProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePeeringProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePeeringProvisioningState(input string) (*PeeringProvisioningState, error) { + vals := map[string]PeeringProvisioningState{ + "deleting": PeeringProvisioningStateDeleting, + "failed": PeeringProvisioningStateFailed, + "succeeded": PeeringProvisioningStateSucceeded, + "updating": PeeringProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PeeringProvisioningState(input) + return &out, nil +} + +type PeeringState string + +const ( + PeeringStateConnected PeeringState = "Connected" + PeeringStateDisconnected PeeringState = "Disconnected" + PeeringStateInitiated PeeringState = "Initiated" +) + +func PossibleValuesForPeeringState() []string { + return []string{ + string(PeeringStateConnected), + string(PeeringStateDisconnected), + string(PeeringStateInitiated), + } +} + +func (s *PeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePeeringState(input string) (*PeeringState, error) { + vals := map[string]PeeringState{ + "connected": PeeringStateConnected, + "disconnected": PeeringStateDisconnected, + "initiated": PeeringStateInitiated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PeeringState(input) + return &out, nil +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/id_virtualnetworkpeering.go b/resource-manager/databricks/2024-05-01/vnetpeering/id_virtualnetworkpeering.go new file mode 100644 index 00000000000..c69b815cd85 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/id_virtualnetworkpeering.go @@ -0,0 +1,139 @@ +package vnetpeering + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkPeeringId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkPeeringId{} + +// VirtualNetworkPeeringId is a struct representing the Resource ID for a Virtual Network Peering +type VirtualNetworkPeeringId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + VirtualNetworkPeeringName string +} + +// NewVirtualNetworkPeeringID returns a new VirtualNetworkPeeringId struct +func NewVirtualNetworkPeeringID(subscriptionId string, resourceGroupName string, workspaceName string, virtualNetworkPeeringName string) VirtualNetworkPeeringId { + return VirtualNetworkPeeringId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + VirtualNetworkPeeringName: virtualNetworkPeeringName, + } +} + +// ParseVirtualNetworkPeeringID parses 'input' into a VirtualNetworkPeeringId +func ParseVirtualNetworkPeeringID(input string) (*VirtualNetworkPeeringId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkPeeringId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkPeeringId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkPeeringIDInsensitively parses 'input' case-insensitively into a VirtualNetworkPeeringId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkPeeringIDInsensitively(input string) (*VirtualNetworkPeeringId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkPeeringId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkPeeringId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkPeeringId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.VirtualNetworkPeeringName, ok = input.Parsed["virtualNetworkPeeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkPeeringName", input) + } + + return nil +} + +// ValidateVirtualNetworkPeeringID checks that 'input' can be parsed as a Virtual Network Peering ID +func ValidateVirtualNetworkPeeringID(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 := ParseVirtualNetworkPeeringID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Peering ID +func (id VirtualNetworkPeeringId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Databricks/workspaces/%s/virtualNetworkPeerings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.VirtualNetworkPeeringName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Peering ID +func (id VirtualNetworkPeeringId) 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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + resourceids.StaticSegment("staticVirtualNetworkPeerings", "virtualNetworkPeerings", "virtualNetworkPeerings"), + resourceids.UserSpecifiedSegment("virtualNetworkPeeringName", "virtualNetworkPeeringValue"), + } +} + +// String returns a human-readable description of this Virtual Network Peering ID +func (id VirtualNetworkPeeringId) 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("Virtual Network Peering Name: %q", id.VirtualNetworkPeeringName), + } + return fmt.Sprintf("Virtual Network Peering (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/id_virtualnetworkpeering_test.go b/resource-manager/databricks/2024-05-01/vnetpeering/id_virtualnetworkpeering_test.go new file mode 100644 index 00000000000..5632c2c100b --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/id_virtualnetworkpeering_test.go @@ -0,0 +1,327 @@ +package vnetpeering + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualNetworkPeeringId{} + +func TestNewVirtualNetworkPeeringID(t *testing.T) { + id := NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "virtualNetworkPeeringValue") + + 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.VirtualNetworkPeeringName != "virtualNetworkPeeringValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkPeeringName'", id.VirtualNetworkPeeringName, "virtualNetworkPeeringValue") + } +} + +func TestFormatVirtualNetworkPeeringID(t *testing.T) { + actual := NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "virtualNetworkPeeringValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/virtualNetworkPeerings/virtualNetworkPeeringValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkPeeringID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkPeeringId + }{ + { + // 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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/virtualNetworkPeerings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/virtualNetworkPeerings/virtualNetworkPeeringValue", + Expected: &VirtualNetworkPeeringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + VirtualNetworkPeeringName: "virtualNetworkPeeringValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/virtualNetworkPeerings/virtualNetworkPeeringValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkPeeringID(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.VirtualNetworkPeeringName != v.Expected.VirtualNetworkPeeringName { + t.Fatalf("Expected %q but got %q for VirtualNetworkPeeringName", v.Expected.VirtualNetworkPeeringName, actual.VirtualNetworkPeeringName) + } + + } +} + +func TestParseVirtualNetworkPeeringIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkPeeringId + }{ + { + // 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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/virtualNetworkPeerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/vIrTuAlNeTwOrKpEeRiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/virtualNetworkPeerings/virtualNetworkPeeringValue", + Expected: &VirtualNetworkPeeringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + VirtualNetworkPeeringName: "virtualNetworkPeeringValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces/workspaceValue/virtualNetworkPeerings/virtualNetworkPeeringValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/vIrTuAlNeTwOrKpEeRiNgS/vIrTuAlNeTwOrKpEeRiNgVaLuE", + Expected: &VirtualNetworkPeeringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + VirtualNetworkPeeringName: "vIrTuAlNeTwOrKpEeRiNgVaLuE", + }, + }, + { + // 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.dAtAbRiCkS/wOrKsPaCeS/wOrKsPaCeVaLuE/vIrTuAlNeTwOrKpEeRiNgS/vIrTuAlNeTwOrKpEeRiNgVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkPeeringIDInsensitively(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.VirtualNetworkPeeringName != v.Expected.VirtualNetworkPeeringName { + t.Fatalf("Expected %q but got %q for VirtualNetworkPeeringName", v.Expected.VirtualNetworkPeeringName, actual.VirtualNetworkPeeringName) + } + + } +} + +func TestSegmentsForVirtualNetworkPeeringId(t *testing.T) { + segments := VirtualNetworkPeeringId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkPeeringId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/id_workspace.go b/resource-manager/databricks/2024-05-01/vnetpeering/id_workspace.go new file mode 100644 index 00000000000..763c748e5e4 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/id_workspace.go @@ -0,0 +1,130 @@ +package vnetpeering + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return 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.Databricks/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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + 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/resource-manager/databricks/2024-05-01/vnetpeering/id_workspace_test.go b/resource-manager/databricks/2024-05-01/vnetpeering/id_workspace_test.go new file mode 100644 index 00000000000..d24e471da22 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/id_workspace_test.go @@ -0,0 +1,282 @@ +package vnetpeering + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.dAtAbRiCkS/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.dAtAbRiCkS/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/resource-manager/databricks/2024-05-01/vnetpeering/method_createorupdate.go b/resource-manager/databricks/2024-05-01/vnetpeering/method_createorupdate.go new file mode 100644 index 00000000000..ae8ea15c159 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/method_createorupdate.go @@ -0,0 +1,75 @@ +package vnetpeering + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkPeering +} + +// CreateOrUpdate ... +func (c VNetPeeringClient) CreateOrUpdate(ctx context.Context, id VirtualNetworkPeeringId, input VirtualNetworkPeering) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VNetPeeringClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualNetworkPeeringId, input VirtualNetworkPeering) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/method_delete.go b/resource-manager/databricks/2024-05-01/vnetpeering/method_delete.go new file mode 100644 index 00000000000..8c95c41e46b --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/method_delete.go @@ -0,0 +1,71 @@ +package vnetpeering + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VNetPeeringClient) Delete(ctx context.Context, id VirtualNetworkPeeringId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VNetPeeringClient) DeleteThenPoll(ctx context.Context, id VirtualNetworkPeeringId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/method_get.go b/resource-manager/databricks/2024-05-01/vnetpeering/method_get.go new file mode 100644 index 00000000000..7a39c3f6b64 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/method_get.go @@ -0,0 +1,55 @@ +package vnetpeering + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkPeering +} + +// Get ... +func (c VNetPeeringClient) Get(ctx context.Context, id VirtualNetworkPeeringId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualNetworkPeering + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/method_listbyworkspace.go b/resource-manager/databricks/2024-05-01/vnetpeering/method_listbyworkspace.go new file mode 100644 index 00000000000..dc1641c5a7e --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/method_listbyworkspace.go @@ -0,0 +1,91 @@ +package vnetpeering + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkPeering +} + +type ListByWorkspaceCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkPeering +} + +// ListByWorkspace ... +func (c VNetPeeringClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (result ListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkPeerings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkPeering `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByWorkspaceComplete retrieves all the results into a single object +func (c VNetPeeringClient) ListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (ListByWorkspaceCompleteResult, error) { + return c.ListByWorkspaceCompleteMatchingPredicate(ctx, id, VirtualNetworkPeeringOperationPredicate{}) +} + +// ListByWorkspaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VNetPeeringClient) ListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate VirtualNetworkPeeringOperationPredicate) (result ListByWorkspaceCompleteResult, err error) { + items := make([]VirtualNetworkPeering, 0) + + resp, err := c.ListByWorkspace(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByWorkspaceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/model_addressspace.go b/resource-manager/databricks/2024-05-01/vnetpeering/model_addressspace.go new file mode 100644 index 00000000000..a0274d74e9c --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/model_addressspace.go @@ -0,0 +1,8 @@ +package vnetpeering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeering.go b/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeering.go new file mode 100644 index 00000000000..dfb94487771 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeering.go @@ -0,0 +1,11 @@ +package vnetpeering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeering struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties VirtualNetworkPeeringPropertiesFormat `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformat.go b/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformat.go new file mode 100644 index 00000000000..3be4e60e0be --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformat.go @@ -0,0 +1,17 @@ +package vnetpeering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeeringPropertiesFormat struct { + AllowForwardedTraffic *bool `json:"allowForwardedTraffic,omitempty"` + AllowGatewayTransit *bool `json:"allowGatewayTransit,omitempty"` + AllowVirtualNetworkAccess *bool `json:"allowVirtualNetworkAccess,omitempty"` + DatabricksAddressSpace *AddressSpace `json:"databricksAddressSpace,omitempty"` + DatabricksVirtualNetwork *VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork `json:"databricksVirtualNetwork,omitempty"` + PeeringState *PeeringState `json:"peeringState,omitempty"` + ProvisioningState *PeeringProvisioningState `json:"provisioningState,omitempty"` + RemoteAddressSpace *AddressSpace `json:"remoteAddressSpace,omitempty"` + RemoteVirtualNetwork VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork `json:"remoteVirtualNetwork"` + UseRemoteGateways *bool `json:"useRemoteGateways,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformatdatabricksvirtualnetwork.go b/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformatdatabricksvirtualnetwork.go new file mode 100644 index 00000000000..a9cd8bd10ff --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformatdatabricksvirtualnetwork.go @@ -0,0 +1,8 @@ +package vnetpeering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeeringPropertiesFormatDatabricksVirtualNetwork struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformatremotevirtualnetwork.go b/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformatremotevirtualnetwork.go new file mode 100644 index 00000000000..117a1334c29 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/model_virtualnetworkpeeringpropertiesformatremotevirtualnetwork.go @@ -0,0 +1,8 @@ +package vnetpeering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeeringPropertiesFormatRemoteVirtualNetwork struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/predicates.go b/resource-manager/databricks/2024-05-01/vnetpeering/predicates.go new file mode 100644 index 00000000000..bfbfcde0b68 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/predicates.go @@ -0,0 +1,27 @@ +package vnetpeering + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeeringOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p VirtualNetworkPeeringOperationPredicate) Matches(input VirtualNetworkPeering) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/databricks/2024-05-01/vnetpeering/version.go b/resource-manager/databricks/2024-05-01/vnetpeering/version.go new file mode 100644 index 00000000000..9dfae6e7ab0 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/vnetpeering/version.go @@ -0,0 +1,12 @@ +package vnetpeering + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/vnetpeering/%s", defaultApiVersion) +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/README.md b/resource-manager/databricks/2024-05-01/workspaces/README.md new file mode 100644 index 00000000000..edfa240488e --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/workspaces` Documentation + +The `workspaces` SDK allows for interaction with the Azure Resource Manager Service `databricks` (API Version `2024-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/databricks/2024-05-01/workspaces" +``` + + +### Client Initialization + +```go +client := workspaces.NewWorkspacesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkspacesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +payload := workspaces.Workspace{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WorkspacesClient.Delete` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +if err := client.DeleteThenPoll(ctx, id, workspaces.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WorkspacesClient.Get` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkspacesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkspacesClient.Update` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + +payload := workspaces.WorkspaceUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/databricks/2024-05-01/workspaces/client.go b/resource-manager/databricks/2024-05-01/workspaces/client.go new file mode 100644 index 00000000000..d599252c05c --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/client.go @@ -0,0 +1,26 @@ +package workspaces + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacesClient struct { + Client *resourcemanager.Client +} + +func NewWorkspacesClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkspacesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "workspaces", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkspacesClient: %+v", err) + } + + return &WorkspacesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/constants.go b/resource-manager/databricks/2024-05-01/workspaces/constants.go new file mode 100644 index 00000000000..85e284f5362 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/constants.go @@ -0,0 +1,673 @@ +package workspaces + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomaticClusterUpdateValue string + +const ( + AutomaticClusterUpdateValueDisabled AutomaticClusterUpdateValue = "Disabled" + AutomaticClusterUpdateValueEnabled AutomaticClusterUpdateValue = "Enabled" +) + +func PossibleValuesForAutomaticClusterUpdateValue() []string { + return []string{ + string(AutomaticClusterUpdateValueDisabled), + string(AutomaticClusterUpdateValueEnabled), + } +} + +func (s *AutomaticClusterUpdateValue) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutomaticClusterUpdateValue(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutomaticClusterUpdateValue(input string) (*AutomaticClusterUpdateValue, error) { + vals := map[string]AutomaticClusterUpdateValue{ + "disabled": AutomaticClusterUpdateValueDisabled, + "enabled": AutomaticClusterUpdateValueEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutomaticClusterUpdateValue(input) + return &out, nil +} + +type ComplianceSecurityProfileValue string + +const ( + ComplianceSecurityProfileValueDisabled ComplianceSecurityProfileValue = "Disabled" + ComplianceSecurityProfileValueEnabled ComplianceSecurityProfileValue = "Enabled" +) + +func PossibleValuesForComplianceSecurityProfileValue() []string { + return []string{ + string(ComplianceSecurityProfileValueDisabled), + string(ComplianceSecurityProfileValueEnabled), + } +} + +func (s *ComplianceSecurityProfileValue) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComplianceSecurityProfileValue(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComplianceSecurityProfileValue(input string) (*ComplianceSecurityProfileValue, error) { + vals := map[string]ComplianceSecurityProfileValue{ + "disabled": ComplianceSecurityProfileValueDisabled, + "enabled": ComplianceSecurityProfileValueEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComplianceSecurityProfileValue(input) + return &out, nil +} + +type ComplianceStandard string + +const ( + ComplianceStandardHIPAA ComplianceStandard = "HIPAA" + ComplianceStandardNONE ComplianceStandard = "NONE" + ComplianceStandardPCIDSS ComplianceStandard = "PCI_DSS" +) + +func PossibleValuesForComplianceStandard() []string { + return []string{ + string(ComplianceStandardHIPAA), + string(ComplianceStandardNONE), + string(ComplianceStandardPCIDSS), + } +} + +func (s *ComplianceStandard) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComplianceStandard(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComplianceStandard(input string) (*ComplianceStandard, error) { + vals := map[string]ComplianceStandard{ + "hipaa": ComplianceStandardHIPAA, + "none": ComplianceStandardNONE, + "pci_dss": ComplianceStandardPCIDSS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComplianceStandard(input) + return &out, nil +} + +type CustomParameterType string + +const ( + CustomParameterTypeBool CustomParameterType = "Bool" + CustomParameterTypeObject CustomParameterType = "Object" + CustomParameterTypeString CustomParameterType = "String" +) + +func PossibleValuesForCustomParameterType() []string { + return []string{ + string(CustomParameterTypeBool), + string(CustomParameterTypeObject), + string(CustomParameterTypeString), + } +} + +func (s *CustomParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomParameterType(input string) (*CustomParameterType, error) { + vals := map[string]CustomParameterType{ + "bool": CustomParameterTypeBool, + "object": CustomParameterTypeObject, + "string": CustomParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomParameterType(input) + return &out, nil +} + +type DefaultStorageFirewall string + +const ( + DefaultStorageFirewallDisabled DefaultStorageFirewall = "Disabled" + DefaultStorageFirewallEnabled DefaultStorageFirewall = "Enabled" +) + +func PossibleValuesForDefaultStorageFirewall() []string { + return []string{ + string(DefaultStorageFirewallDisabled), + string(DefaultStorageFirewallEnabled), + } +} + +func (s *DefaultStorageFirewall) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultStorageFirewall(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultStorageFirewall(input string) (*DefaultStorageFirewall, error) { + vals := map[string]DefaultStorageFirewall{ + "disabled": DefaultStorageFirewallDisabled, + "enabled": DefaultStorageFirewallEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultStorageFirewall(input) + return &out, nil +} + +type EncryptionKeySource string + +const ( + EncryptionKeySourceMicrosoftPointKeyvault EncryptionKeySource = "Microsoft.Keyvault" +) + +func PossibleValuesForEncryptionKeySource() []string { + return []string{ + string(EncryptionKeySourceMicrosoftPointKeyvault), + } +} + +func (s *EncryptionKeySource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEncryptionKeySource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEncryptionKeySource(input string) (*EncryptionKeySource, error) { + vals := map[string]EncryptionKeySource{ + "microsoft.keyvault": EncryptionKeySourceMicrosoftPointKeyvault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionKeySource(input) + return &out, nil +} + +type EnhancedSecurityMonitoringValue string + +const ( + EnhancedSecurityMonitoringValueDisabled EnhancedSecurityMonitoringValue = "Disabled" + EnhancedSecurityMonitoringValueEnabled EnhancedSecurityMonitoringValue = "Enabled" +) + +func PossibleValuesForEnhancedSecurityMonitoringValue() []string { + return []string{ + string(EnhancedSecurityMonitoringValueDisabled), + string(EnhancedSecurityMonitoringValueEnabled), + } +} + +func (s *EnhancedSecurityMonitoringValue) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnhancedSecurityMonitoringValue(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnhancedSecurityMonitoringValue(input string) (*EnhancedSecurityMonitoringValue, error) { + vals := map[string]EnhancedSecurityMonitoringValue{ + "disabled": EnhancedSecurityMonitoringValueDisabled, + "enabled": EnhancedSecurityMonitoringValueEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnhancedSecurityMonitoringValue(input) + return &out, nil +} + +type IdentityType string + +const ( + IdentityTypeSystemAssigned IdentityType = "SystemAssigned" + IdentityTypeUserAssigned IdentityType = "UserAssigned" +) + +func PossibleValuesForIdentityType() []string { + return []string{ + string(IdentityTypeSystemAssigned), + string(IdentityTypeUserAssigned), + } +} + +func (s *IdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIdentityType(input string) (*IdentityType, error) { + vals := map[string]IdentityType{ + "systemassigned": IdentityTypeSystemAssigned, + "userassigned": IdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IdentityType(input) + return &out, nil +} + +type InitialType string + +const ( + InitialTypeHiveMetastore InitialType = "HiveMetastore" + InitialTypeUnityCatalog InitialType = "UnityCatalog" +) + +func PossibleValuesForInitialType() []string { + return []string{ + string(InitialTypeHiveMetastore), + string(InitialTypeUnityCatalog), + } +} + +func (s *InitialType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInitialType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInitialType(input string) (*InitialType, error) { + vals := map[string]InitialType{ + "hivemetastore": InitialTypeHiveMetastore, + "unitycatalog": InitialTypeUnityCatalog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InitialType(input) + return &out, nil +} + +type KeySource string + +const ( + KeySourceDefault KeySource = "Default" + KeySourceMicrosoftPointKeyvault KeySource = "Microsoft.Keyvault" +) + +func PossibleValuesForKeySource() []string { + return []string{ + string(KeySourceDefault), + string(KeySourceMicrosoftPointKeyvault), + } +} + +func (s *KeySource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeySource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeySource(input string) (*KeySource, error) { + vals := map[string]KeySource{ + "default": KeySourceDefault, + "microsoft.keyvault": KeySourceMicrosoftPointKeyvault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeySource(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { + return []string{ + string(PrivateLinkServiceConnectionStatusApproved), + string(PrivateLinkServiceConnectionStatusDisconnected), + string(PrivateLinkServiceConnectionStatusPending), + string(PrivateLinkServiceConnectionStatusRejected), + } +} + +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { + vals := map[string]PrivateLinkServiceConnectionStatus{ + "approved": PrivateLinkServiceConnectionStatusApproved, + "disconnected": PrivateLinkServiceConnectionStatusDisconnected, + "pending": PrivateLinkServiceConnectionStatusPending, + "rejected": PrivateLinkServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateReady ProvisioningState = "Ready" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreated), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateReady), + string(ProvisioningStateRunning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "created": ProvisioningStateCreated, + "creating": ProvisioningStateCreating, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "ready": ProvisioningStateReady, + "running": ProvisioningStateRunning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type RequiredNsgRules string + +const ( + RequiredNsgRulesAllRules RequiredNsgRules = "AllRules" + RequiredNsgRulesNoAzureDatabricksRules RequiredNsgRules = "NoAzureDatabricksRules" + RequiredNsgRulesNoAzureServiceRules RequiredNsgRules = "NoAzureServiceRules" +) + +func PossibleValuesForRequiredNsgRules() []string { + return []string{ + string(RequiredNsgRulesAllRules), + string(RequiredNsgRulesNoAzureDatabricksRules), + string(RequiredNsgRulesNoAzureServiceRules), + } +} + +func (s *RequiredNsgRules) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRequiredNsgRules(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRequiredNsgRules(input string) (*RequiredNsgRules, error) { + vals := map[string]RequiredNsgRules{ + "allrules": RequiredNsgRulesAllRules, + "noazuredatabricksrules": RequiredNsgRulesNoAzureDatabricksRules, + "noazureservicerules": RequiredNsgRulesNoAzureServiceRules, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RequiredNsgRules(input) + return &out, nil +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/id_workspace.go b/resource-manager/databricks/2024-05-01/workspaces/id_workspace.go new file mode 100644 index 00000000000..815bf37d843 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/id_workspace.go @@ -0,0 +1,130 @@ +package workspaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := WorkspaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return 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.Databricks/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("staticMicrosoftDatabricks", "Microsoft.Databricks", "Microsoft.Databricks"), + 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/resource-manager/databricks/2024-05-01/workspaces/id_workspace_test.go b/resource-manager/databricks/2024-05-01/workspaces/id_workspace_test.go new file mode 100644 index 00000000000..5ae7a96ff68 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/id_workspace_test.go @@ -0,0 +1,282 @@ +package workspaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.Databricks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtAbRiCkS/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Databricks/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.Databricks/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.dAtAbRiCkS/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.dAtAbRiCkS/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/resource-manager/databricks/2024-05-01/workspaces/method_createorupdate.go b/resource-manager/databricks/2024-05-01/workspaces/method_createorupdate.go new file mode 100644 index 00000000000..cc4deaa2566 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/method_createorupdate.go @@ -0,0 +1,75 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Workspace +} + +// CreateOrUpdate ... +func (c WorkspacesClient) CreateOrUpdate(ctx context.Context, id WorkspaceId, input Workspace) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c 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(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/method_delete.go b/resource-manager/databricks/2024-05-01/workspaces/method_delete.go new file mode 100644 index 00000000000..979b1a59ad7 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/method_delete.go @@ -0,0 +1,99 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + ForceDeletion *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceDeletion != nil { + out.Append("forceDeletion", fmt.Sprintf("%v", *o.ForceDeletion)) + } + return &out +} + +// Delete ... +func (c WorkspacesClient) Delete(ctx context.Context, id WorkspaceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c WorkspacesClient) DeleteThenPoll(ctx context.Context, id WorkspaceId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/method_get.go b/resource-manager/databricks/2024-05-01/workspaces/method_get.go new file mode 100644 index 00000000000..d4a1a279a97 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/method_get.go @@ -0,0 +1,54 @@ +package workspaces + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Workspace +} + +// Get ... +func (c WorkspacesClient) Get(ctx context.Context, id WorkspaceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Workspace + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/method_listbyresourcegroup.go b/resource-manager/databricks/2024-05-01/workspaces/method_listbyresourcegroup.go new file mode 100644 index 00000000000..7ff67cd383d --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Workspace +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Workspace +} + +// ListByResourceGroup ... +func (c WorkspacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Databricks/workspaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Workspace `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c WorkspacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, WorkspaceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkspacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate WorkspaceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Workspace, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/method_listbysubscription.go b/resource-manager/databricks/2024-05-01/workspaces/method_listbysubscription.go new file mode 100644 index 00000000000..ac2688e6ec1 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/method_listbysubscription.go @@ -0,0 +1,92 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Workspace +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Workspace +} + +// ListBySubscription ... +func (c WorkspacesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Databricks/workspaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Workspace `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c WorkspacesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, WorkspaceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkspacesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate WorkspaceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Workspace, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/method_update.go b/resource-manager/databricks/2024-05-01/workspaces/method_update.go new file mode 100644 index 00000000000..2065fc03b6c --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/method_update.go @@ -0,0 +1,75 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Workspace +} + +// Update ... +func (c WorkspacesClient) Update(ctx context.Context, id WorkspaceId, input WorkspaceUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c WorkspacesClient) UpdateThenPoll(ctx context.Context, id WorkspaceId, input WorkspaceUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_automaticclusterupdatedefinition.go b/resource-manager/databricks/2024-05-01/workspaces/model_automaticclusterupdatedefinition.go new file mode 100644 index 00000000000..155168bd980 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_automaticclusterupdatedefinition.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutomaticClusterUpdateDefinition struct { + Value *AutomaticClusterUpdateValue `json:"value,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_compliancesecurityprofiledefinition.go b/resource-manager/databricks/2024-05-01/workspaces/model_compliancesecurityprofiledefinition.go new file mode 100644 index 00000000000..c303cf3f4e8 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_compliancesecurityprofiledefinition.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComplianceSecurityProfileDefinition struct { + ComplianceStandards *[]ComplianceStandard `json:"complianceStandards,omitempty"` + Value *ComplianceSecurityProfileValue `json:"value,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_createdby.go b/resource-manager/databricks/2024-05-01/workspaces/model_createdby.go new file mode 100644 index 00000000000..fa06a35a393 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_createdby.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreatedBy struct { + ApplicationId *string `json:"applicationId,omitempty"` + Oid *string `json:"oid,omitempty"` + Puid *string `json:"puid,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_defaultcatalogproperties.go b/resource-manager/databricks/2024-05-01/workspaces/model_defaultcatalogproperties.go new file mode 100644 index 00000000000..511ef1ad94c --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_defaultcatalogproperties.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultCatalogProperties struct { + InitialName *string `json:"initialName,omitempty"` + InitialType *InitialType `json:"initialType,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_encryption.go b/resource-manager/databricks/2024-05-01/workspaces/model_encryption.go new file mode 100644 index 00000000000..3d37fddd7e5 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_encryption.go @@ -0,0 +1,11 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Encryption struct { + KeyName *string `json:"KeyName,omitempty"` + KeySource *KeySource `json:"keySource,omitempty"` + Keyvaulturi *string `json:"keyvaulturi,omitempty"` + Keyversion *string `json:"keyversion,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_encryptionentitiesdefinition.go b/resource-manager/databricks/2024-05-01/workspaces/model_encryptionentitiesdefinition.go new file mode 100644 index 00000000000..df2cae1410b --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_encryptionentitiesdefinition.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionEntitiesDefinition struct { + ManagedDisk *ManagedDiskEncryption `json:"managedDisk,omitempty"` + ManagedServices *EncryptionV2 `json:"managedServices,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_encryptionv2.go b/resource-manager/databricks/2024-05-01/workspaces/model_encryptionv2.go new file mode 100644 index 00000000000..1569f86ef50 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_encryptionv2.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionV2 struct { + KeySource EncryptionKeySource `json:"keySource"` + KeyVaultProperties *EncryptionV2KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_encryptionv2keyvaultproperties.go b/resource-manager/databricks/2024-05-01/workspaces/model_encryptionv2keyvaultproperties.go new file mode 100644 index 00000000000..86adbd8c6a5 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_encryptionv2keyvaultproperties.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionV2KeyVaultProperties struct { + KeyName string `json:"keyName"` + KeyVaultUri string `json:"keyVaultUri"` + KeyVersion string `json:"keyVersion"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_enhancedsecuritycompliancedefinition.go b/resource-manager/databricks/2024-05-01/workspaces/model_enhancedsecuritycompliancedefinition.go new file mode 100644 index 00000000000..dad47ecca29 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_enhancedsecuritycompliancedefinition.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnhancedSecurityComplianceDefinition struct { + AutomaticClusterUpdate *AutomaticClusterUpdateDefinition `json:"automaticClusterUpdate,omitempty"` + ComplianceSecurityProfile *ComplianceSecurityProfileDefinition `json:"complianceSecurityProfile,omitempty"` + EnhancedSecurityMonitoring *EnhancedSecurityMonitoringDefinition `json:"enhancedSecurityMonitoring,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_enhancedsecuritymonitoringdefinition.go b/resource-manager/databricks/2024-05-01/workspaces/model_enhancedsecuritymonitoringdefinition.go new file mode 100644 index 00000000000..e5685c4a698 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_enhancedsecuritymonitoringdefinition.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnhancedSecurityMonitoringDefinition struct { + Value *EnhancedSecurityMonitoringValue `json:"value,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_manageddiskencryption.go b/resource-manager/databricks/2024-05-01/workspaces/model_manageddiskencryption.go new file mode 100644 index 00000000000..0374f44bdc3 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_manageddiskencryption.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedDiskEncryption struct { + KeySource EncryptionKeySource `json:"keySource"` + KeyVaultProperties ManagedDiskEncryptionKeyVaultProperties `json:"keyVaultProperties"` + RotationToLatestKeyVersionEnabled *bool `json:"rotationToLatestKeyVersionEnabled,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_manageddiskencryptionkeyvaultproperties.go b/resource-manager/databricks/2024-05-01/workspaces/model_manageddiskencryptionkeyvaultproperties.go new file mode 100644 index 00000000000..a82d0ea2aa4 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_manageddiskencryptionkeyvaultproperties.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedDiskEncryptionKeyVaultProperties struct { + KeyName string `json:"keyName"` + KeyVaultUri string `json:"keyVaultUri"` + KeyVersion string `json:"keyVersion"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_managedidentityconfiguration.go b/resource-manager/databricks/2024-05-01/workspaces/model_managedidentityconfiguration.go new file mode 100644 index 00000000000..aeea7f937c8 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_managedidentityconfiguration.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedIdentityConfiguration struct { + PrincipalId *string `json:"principalId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_privateendpoint.go b/resource-manager/databricks/2024-05-01/workspaces/model_privateendpoint.go new file mode 100644 index 00000000000..9f81ff8b836 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_privateendpoint.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_privateendpointconnection.go b/resource-manager/databricks/2024-05-01/workspaces/model_privateendpointconnection.go new file mode 100644 index 00000000000..aee2db4a4b3 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties PrivateEndpointConnectionProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_privateendpointconnectionproperties.go b/resource-manager/databricks/2024-05-01/workspaces/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..f84ae62a2e0 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_privatelinkserviceconnectionstate.go b/resource-manager/databricks/2024-05-01/workspaces/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..e56c0b779bd --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status PrivateLinkServiceConnectionStatus `json:"status"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_sku.go b/resource-manager/databricks/2024-05-01/workspaces/model_sku.go new file mode 100644 index 00000000000..e5316e27b30 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_sku.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name string `json:"name"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspace.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspace.go new file mode 100644 index 00000000000..2a205ac1902 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspace.go @@ -0,0 +1,19 @@ +package workspaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Workspace struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties WorkspaceProperties `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustombooleanparameter.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustombooleanparameter.go new file mode 100644 index 00000000000..a2e256bd2f0 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustombooleanparameter.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceCustomBooleanParameter struct { + Type *CustomParameterType `json:"type,omitempty"` + Value bool `json:"value"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomobjectparameter.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomobjectparameter.go new file mode 100644 index 00000000000..85cfe098391 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomobjectparameter.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceCustomObjectParameter struct { + Type *CustomParameterType `json:"type,omitempty"` + Value interface{} `json:"value"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomparameters.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomparameters.go new file mode 100644 index 00000000000..3a48c1320d0 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomparameters.go @@ -0,0 +1,23 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceCustomParameters struct { + AmlWorkspaceId *WorkspaceCustomStringParameter `json:"amlWorkspaceId,omitempty"` + CustomPrivateSubnetName *WorkspaceCustomStringParameter `json:"customPrivateSubnetName,omitempty"` + CustomPublicSubnetName *WorkspaceCustomStringParameter `json:"customPublicSubnetName,omitempty"` + CustomVirtualNetworkId *WorkspaceCustomStringParameter `json:"customVirtualNetworkId,omitempty"` + EnableNoPublicIP *WorkspaceNoPublicIPBooleanParameter `json:"enableNoPublicIp,omitempty"` + Encryption *WorkspaceEncryptionParameter `json:"encryption,omitempty"` + LoadBalancerBackendPoolName *WorkspaceCustomStringParameter `json:"loadBalancerBackendPoolName,omitempty"` + LoadBalancerId *WorkspaceCustomStringParameter `json:"loadBalancerId,omitempty"` + NatGatewayName *WorkspaceCustomStringParameter `json:"natGatewayName,omitempty"` + PrepareEncryption *WorkspaceCustomBooleanParameter `json:"prepareEncryption,omitempty"` + PublicIPName *WorkspaceCustomStringParameter `json:"publicIpName,omitempty"` + RequireInfrastructureEncryption *WorkspaceCustomBooleanParameter `json:"requireInfrastructureEncryption,omitempty"` + ResourceTags *WorkspaceCustomObjectParameter `json:"resourceTags,omitempty"` + StorageAccountName *WorkspaceCustomStringParameter `json:"storageAccountName,omitempty"` + StorageAccountSkuName *WorkspaceCustomStringParameter `json:"storageAccountSkuName,omitempty"` + VnetAddressPrefix *WorkspaceCustomStringParameter `json:"vnetAddressPrefix,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomstringparameter.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomstringparameter.go new file mode 100644 index 00000000000..c983ffae968 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspacecustomstringparameter.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceCustomStringParameter struct { + Type *CustomParameterType `json:"type,omitempty"` + Value string `json:"value"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspaceencryptionparameter.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspaceencryptionparameter.go new file mode 100644 index 00000000000..551ca748c04 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspaceencryptionparameter.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceEncryptionParameter struct { + Type *CustomParameterType `json:"type,omitempty"` + Value *Encryption `json:"value,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspacenopublicipbooleanparameter.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspacenopublicipbooleanparameter.go new file mode 100644 index 00000000000..67ec96998d6 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspacenopublicipbooleanparameter.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceNoPublicIPBooleanParameter struct { + Type *CustomParameterType `json:"type,omitempty"` + Value bool `json:"value"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspaceproperties.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspaceproperties.go new file mode 100644 index 00000000000..4d9c704b2d6 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspaceproperties.go @@ -0,0 +1,47 @@ +package workspaces + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceProperties struct { + AccessConnector *WorkspacePropertiesAccessConnector `json:"accessConnector,omitempty"` + Authorizations *[]WorkspaceProviderAuthorization `json:"authorizations,omitempty"` + CreatedBy *CreatedBy `json:"createdBy,omitempty"` + CreatedDateTime *string `json:"createdDateTime,omitempty"` + DefaultCatalog *DefaultCatalogProperties `json:"defaultCatalog,omitempty"` + DefaultStorageFirewall *DefaultStorageFirewall `json:"defaultStorageFirewall,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + Encryption *WorkspacePropertiesEncryption `json:"encryption,omitempty"` + EnhancedSecurityCompliance *EnhancedSecurityComplianceDefinition `json:"enhancedSecurityCompliance,omitempty"` + IsUcEnabled *bool `json:"isUcEnabled,omitempty"` + ManagedDiskIdentity *ManagedIdentityConfiguration `json:"managedDiskIdentity,omitempty"` + ManagedResourceGroupId string `json:"managedResourceGroupId"` + Parameters *WorkspaceCustomParameters `json:"parameters,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + RequiredNsgRules *RequiredNsgRules `json:"requiredNsgRules,omitempty"` + StorageAccountIdentity *ManagedIdentityConfiguration `json:"storageAccountIdentity,omitempty"` + UiDefinitionUri *string `json:"uiDefinitionUri,omitempty"` + UpdatedBy *CreatedBy `json:"updatedBy,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceUrl *string `json:"workspaceUrl,omitempty"` +} + +func (o *WorkspaceProperties) GetCreatedDateTimeAsTime() (*time.Time, error) { + if o.CreatedDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkspaceProperties) SetCreatedDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedDateTime = &formatted +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspacepropertiesaccessconnector.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspacepropertiesaccessconnector.go new file mode 100644 index 00000000000..e7f2faeb9a8 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspacepropertiesaccessconnector.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePropertiesAccessConnector struct { + Id string `json:"id"` + IdentityType IdentityType `json:"identityType"` + UserAssignedIdentityId *string `json:"userAssignedIdentityId,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspacepropertiesencryption.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspacepropertiesencryption.go new file mode 100644 index 00000000000..ddb3625ee74 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspacepropertiesencryption.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePropertiesEncryption struct { + Entities EncryptionEntitiesDefinition `json:"entities"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspaceproviderauthorization.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspaceproviderauthorization.go new file mode 100644 index 00000000000..98d6f732126 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspaceproviderauthorization.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceProviderAuthorization struct { + PrincipalId string `json:"principalId"` + RoleDefinitionId string `json:"roleDefinitionId"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/model_workspaceupdate.go b/resource-manager/databricks/2024-05-01/workspaces/model_workspaceupdate.go new file mode 100644 index 00000000000..079a43eda11 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/model_workspaceupdate.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceUpdate struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/predicates.go b/resource-manager/databricks/2024-05-01/workspaces/predicates.go new file mode 100644 index 00000000000..487159d40b2 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/predicates.go @@ -0,0 +1,32 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkspaceOperationPredicate) Matches(input Workspace) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/databricks/2024-05-01/workspaces/version.go b/resource-manager/databricks/2024-05-01/workspaces/version.go new file mode 100644 index 00000000000..743af8d4e07 --- /dev/null +++ b/resource-manager/databricks/2024-05-01/workspaces/version.go @@ -0,0 +1,12 @@ +package workspaces + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/workspaces/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/README.md b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/README.md new file mode 100644 index 00000000000..0d20799d77a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork` Documentation + +The `attacheddatanetwork` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork" +``` + + +### Client Initialization + +```go +client := attacheddatanetwork.NewAttachedDataNetworkClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AttachedDataNetworkClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := attacheddatanetwork.NewAttachedDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue", "attachedDataNetworkValue") + +payload := attacheddatanetwork.AttachedDataNetwork{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AttachedDataNetworkClient.Delete` + +```go +ctx := context.TODO() +id := attacheddatanetwork.NewAttachedDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue", "attachedDataNetworkValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AttachedDataNetworkClient.Get` + +```go +ctx := context.TODO() +id := attacheddatanetwork.NewAttachedDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue", "attachedDataNetworkValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AttachedDataNetworkClient.UpdateTags` + +```go +ctx := context.TODO() +id := attacheddatanetwork.NewAttachedDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue", "attachedDataNetworkValue") + +payload := attacheddatanetwork.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/client.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/client.go new file mode 100644 index 00000000000..19812ddb299 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/client.go @@ -0,0 +1,26 @@ +package attacheddatanetwork + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetworkClient struct { + Client *resourcemanager.Client +} + +func NewAttachedDataNetworkClientWithBaseURI(sdkApi sdkEnv.Api) (*AttachedDataNetworkClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "attacheddatanetwork", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AttachedDataNetworkClient: %+v", err) + } + + return &AttachedDataNetworkClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/constants.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/constants.go new file mode 100644 index 00000000000..9df4b1e3293 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/constants.go @@ -0,0 +1,107 @@ +package attacheddatanetwork + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NaptEnabled string + +const ( + NaptEnabledDisabled NaptEnabled = "Disabled" + NaptEnabledEnabled NaptEnabled = "Enabled" +) + +func PossibleValuesForNaptEnabled() []string { + return []string{ + string(NaptEnabledDisabled), + string(NaptEnabledEnabled), + } +} + +func (s *NaptEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNaptEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNaptEnabled(input string) (*NaptEnabled, error) { + vals := map[string]NaptEnabled{ + "disabled": NaptEnabledDisabled, + "enabled": NaptEnabledEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NaptEnabled(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/id_attacheddatanetwork.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/id_attacheddatanetwork.go new file mode 100644 index 00000000000..e56bbcceb35 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/id_attacheddatanetwork.go @@ -0,0 +1,148 @@ +package attacheddatanetwork + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AttachedDataNetworkId{}) +} + +var _ resourceids.ResourceId = &AttachedDataNetworkId{} + +// AttachedDataNetworkId is a struct representing the Resource ID for a Attached Data Network +type AttachedDataNetworkId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string + PacketCoreDataPlaneName string + AttachedDataNetworkName string +} + +// NewAttachedDataNetworkID returns a new AttachedDataNetworkId struct +func NewAttachedDataNetworkID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, attachedDataNetworkName string) AttachedDataNetworkId { + return AttachedDataNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + PacketCoreDataPlaneName: packetCoreDataPlaneName, + AttachedDataNetworkName: attachedDataNetworkName, + } +} + +// ParseAttachedDataNetworkID parses 'input' into a AttachedDataNetworkId +func ParseAttachedDataNetworkID(input string) (*AttachedDataNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&AttachedDataNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AttachedDataNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAttachedDataNetworkIDInsensitively parses 'input' case-insensitively into a AttachedDataNetworkId +// note: this method should only be used for API response data and not user input +func ParseAttachedDataNetworkIDInsensitively(input string) (*AttachedDataNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&AttachedDataNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AttachedDataNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AttachedDataNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + if id.PacketCoreDataPlaneName, ok = input.Parsed["packetCoreDataPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreDataPlaneName", input) + } + + if id.AttachedDataNetworkName, ok = input.Parsed["attachedDataNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "attachedDataNetworkName", input) + } + + return nil +} + +// ValidateAttachedDataNetworkID checks that 'input' can be parsed as a Attached Data Network ID +func ValidateAttachedDataNetworkID(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 := ParseAttachedDataNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Attached Data Network ID +func (id AttachedDataNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s/packetCoreDataPlanes/%s/attachedDataNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName, id.PacketCoreDataPlaneName, id.AttachedDataNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Attached Data Network ID +func (id AttachedDataNetworkId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + resourceids.StaticSegment("staticPacketCoreDataPlanes", "packetCoreDataPlanes", "packetCoreDataPlanes"), + resourceids.UserSpecifiedSegment("packetCoreDataPlaneName", "packetCoreDataPlaneValue"), + resourceids.StaticSegment("staticAttachedDataNetworks", "attachedDataNetworks", "attachedDataNetworks"), + resourceids.UserSpecifiedSegment("attachedDataNetworkName", "attachedDataNetworkValue"), + } +} + +// String returns a human-readable description of this Attached Data Network ID +func (id AttachedDataNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + fmt.Sprintf("Packet Core Data Plane Name: %q", id.PacketCoreDataPlaneName), + fmt.Sprintf("Attached Data Network Name: %q", id.AttachedDataNetworkName), + } + return fmt.Sprintf("Attached Data Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/id_attacheddatanetwork_test.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/id_attacheddatanetwork_test.go new file mode 100644 index 00000000000..08ec8aabb45 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/id_attacheddatanetwork_test.go @@ -0,0 +1,372 @@ +package attacheddatanetwork + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AttachedDataNetworkId{} + +func TestNewAttachedDataNetworkID(t *testing.T) { + id := NewAttachedDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue", "attachedDataNetworkValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } + + if id.PacketCoreDataPlaneName != "packetCoreDataPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreDataPlaneName'", id.PacketCoreDataPlaneName, "packetCoreDataPlaneValue") + } + + if id.AttachedDataNetworkName != "attachedDataNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'AttachedDataNetworkName'", id.AttachedDataNetworkName, "attachedDataNetworkValue") + } +} + +func TestFormatAttachedDataNetworkID(t *testing.T) { + actual := NewAttachedDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue", "attachedDataNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/attachedDataNetworks/attachedDataNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAttachedDataNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AttachedDataNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/attachedDataNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/attachedDataNetworks/attachedDataNetworkValue", + Expected: &AttachedDataNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + PacketCoreDataPlaneName: "packetCoreDataPlaneValue", + AttachedDataNetworkName: "attachedDataNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/attachedDataNetworks/attachedDataNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAttachedDataNetworkID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.PacketCoreDataPlaneName != v.Expected.PacketCoreDataPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreDataPlaneName", v.Expected.PacketCoreDataPlaneName, actual.PacketCoreDataPlaneName) + } + + if actual.AttachedDataNetworkName != v.Expected.AttachedDataNetworkName { + t.Fatalf("Expected %q but got %q for AttachedDataNetworkName", v.Expected.AttachedDataNetworkName, actual.AttachedDataNetworkName) + } + + } +} + +func TestParseAttachedDataNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AttachedDataNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS/pAcKeTcOrEdAtApLaNeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/attachedDataNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS/pAcKeTcOrEdAtApLaNeVaLuE/aTtAcHeDdAtAnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/attachedDataNetworks/attachedDataNetworkValue", + Expected: &AttachedDataNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + PacketCoreDataPlaneName: "packetCoreDataPlaneValue", + AttachedDataNetworkName: "attachedDataNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/attachedDataNetworks/attachedDataNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS/pAcKeTcOrEdAtApLaNeVaLuE/aTtAcHeDdAtAnEtWoRkS/aTtAcHeDdAtAnEtWoRkVaLuE", + Expected: &AttachedDataNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + PacketCoreDataPlaneName: "pAcKeTcOrEdAtApLaNeVaLuE", + AttachedDataNetworkName: "aTtAcHeDdAtAnEtWoRkVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS/pAcKeTcOrEdAtApLaNeVaLuE/aTtAcHeDdAtAnEtWoRkS/aTtAcHeDdAtAnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAttachedDataNetworkIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.PacketCoreDataPlaneName != v.Expected.PacketCoreDataPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreDataPlaneName", v.Expected.PacketCoreDataPlaneName, actual.PacketCoreDataPlaneName) + } + + if actual.AttachedDataNetworkName != v.Expected.AttachedDataNetworkName { + t.Fatalf("Expected %q but got %q for AttachedDataNetworkName", v.Expected.AttachedDataNetworkName, actual.AttachedDataNetworkName) + } + + } +} + +func TestSegmentsForAttachedDataNetworkId(t *testing.T) { + segments := AttachedDataNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AttachedDataNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_createorupdate.go new file mode 100644 index 00000000000..ee237bade62 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_createorupdate.go @@ -0,0 +1,75 @@ +package attacheddatanetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AttachedDataNetwork +} + +// CreateOrUpdate ... +func (c AttachedDataNetworkClient) CreateOrUpdate(ctx context.Context, id AttachedDataNetworkId, input AttachedDataNetwork) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AttachedDataNetworkClient) CreateOrUpdateThenPoll(ctx context.Context, id AttachedDataNetworkId, input AttachedDataNetwork) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_delete.go new file mode 100644 index 00000000000..6a22c1af5bd --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_delete.go @@ -0,0 +1,71 @@ +package attacheddatanetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AttachedDataNetworkClient) Delete(ctx context.Context, id AttachedDataNetworkId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AttachedDataNetworkClient) DeleteThenPoll(ctx context.Context, id AttachedDataNetworkId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_get.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_get.go new file mode 100644 index 00000000000..0ddf3e539dd --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_get.go @@ -0,0 +1,54 @@ +package attacheddatanetwork + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AttachedDataNetwork +} + +// Get ... +func (c AttachedDataNetworkClient) Get(ctx context.Context, id AttachedDataNetworkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AttachedDataNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_updatetags.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_updatetags.go new file mode 100644 index 00000000000..61cfb29e437 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/method_updatetags.go @@ -0,0 +1,58 @@ +package attacheddatanetwork + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AttachedDataNetwork +} + +// UpdateTags ... +func (c AttachedDataNetworkClient) UpdateTags(ctx context.Context, id AttachedDataNetworkId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AttachedDataNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_attacheddatanetwork.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_attacheddatanetwork.go new file mode 100644 index 00000000000..16ac487d681 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_attacheddatanetwork.go @@ -0,0 +1,18 @@ +package attacheddatanetwork + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetwork struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties AttachedDataNetworkPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_attacheddatanetworkpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_attacheddatanetworkpropertiesformat.go new file mode 100644 index 00000000000..85e788604be --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_attacheddatanetworkpropertiesformat.go @@ -0,0 +1,13 @@ +package attacheddatanetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetworkPropertiesFormat struct { + DnsAddresses []string `json:"dnsAddresses"` + NaptConfiguration *NaptConfiguration `json:"naptConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + UserEquipmentAddressPoolPrefix *[]string `json:"userEquipmentAddressPoolPrefix,omitempty"` + UserEquipmentStaticAddressPoolPrefix *[]string `json:"userEquipmentStaticAddressPoolPrefix,omitempty"` + UserPlaneDataInterface InterfaceProperties `json:"userPlaneDataInterface"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_interfaceproperties.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_interfaceproperties.go new file mode 100644 index 00000000000..68c4e84cd12 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_interfaceproperties.go @@ -0,0 +1,14 @@ +package attacheddatanetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InterfaceProperties struct { + BfdIPv4Endpoints *[]string `json:"bfdIpv4Endpoints,omitempty"` + IPv4Address *string `json:"ipv4Address,omitempty"` + IPv4AddressList *[]string `json:"ipv4AddressList,omitempty"` + IPv4Gateway *string `json:"ipv4Gateway,omitempty"` + IPv4Subnet *string `json:"ipv4Subnet,omitempty"` + Name *string `json:"name,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_naptconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_naptconfiguration.go new file mode 100644 index 00000000000..db0c4f0c12c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_naptconfiguration.go @@ -0,0 +1,12 @@ +package attacheddatanetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NaptConfiguration struct { + Enabled *NaptEnabled `json:"enabled,omitempty"` + PinholeLimits *int64 `json:"pinholeLimits,omitempty"` + PinholeTimeouts *PinholeTimeouts `json:"pinholeTimeouts,omitempty"` + PortRange *PortRange `json:"portRange,omitempty"` + PortReuseHoldTime *PortReuseHoldTimes `json:"portReuseHoldTime,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_pinholetimeouts.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_pinholetimeouts.go new file mode 100644 index 00000000000..0d2f93a70da --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_pinholetimeouts.go @@ -0,0 +1,10 @@ +package attacheddatanetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PinholeTimeouts struct { + Icmp *int64 `json:"icmp,omitempty"` + Tcp *int64 `json:"tcp,omitempty"` + Udp *int64 `json:"udp,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_portrange.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_portrange.go new file mode 100644 index 00000000000..6a33ad97c48 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_portrange.go @@ -0,0 +1,9 @@ +package attacheddatanetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PortRange struct { + MaxPort *int64 `json:"maxPort,omitempty"` + MinPort *int64 `json:"minPort,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_portreuseholdtimes.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_portreuseholdtimes.go new file mode 100644 index 00000000000..445b7aba57d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_portreuseholdtimes.go @@ -0,0 +1,9 @@ +package attacheddatanetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PortReuseHoldTimes struct { + Tcp *int64 `json:"tcp,omitempty"` + Udp *int64 `json:"udp,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_tagsobject.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_tagsobject.go new file mode 100644 index 00000000000..dd7c1fd8074 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/model_tagsobject.go @@ -0,0 +1,8 @@ +package attacheddatanetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/version.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/version.go new file mode 100644 index 00000000000..b7f3dc07121 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork/version.go @@ -0,0 +1,12 @@ +package attacheddatanetwork + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/attacheddatanetwork/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/README.md b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/README.md new file mode 100644 index 00000000000..4d50e2c05ba --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks` Documentation + +The `attacheddatanetworks` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks" +``` + + +### Client Initialization + +```go +client := attacheddatanetworks.NewAttachedDataNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AttachedDataNetworksClient.ListByPacketCoreDataPlane` + +```go +ctx := context.TODO() +id := attacheddatanetworks.NewPacketCoreDataPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue") + +// alternatively `client.ListByPacketCoreDataPlane(ctx, id)` can be used to do batched pagination +items, err := client.ListByPacketCoreDataPlaneComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/client.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/client.go new file mode 100644 index 00000000000..27de18519a5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/client.go @@ -0,0 +1,26 @@ +package attacheddatanetworks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetworksClient struct { + Client *resourcemanager.Client +} + +func NewAttachedDataNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*AttachedDataNetworksClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "attacheddatanetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AttachedDataNetworksClient: %+v", err) + } + + return &AttachedDataNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/constants.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/constants.go new file mode 100644 index 00000000000..c42e7dcff5c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/constants.go @@ -0,0 +1,107 @@ +package attacheddatanetworks + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NaptEnabled string + +const ( + NaptEnabledDisabled NaptEnabled = "Disabled" + NaptEnabledEnabled NaptEnabled = "Enabled" +) + +func PossibleValuesForNaptEnabled() []string { + return []string{ + string(NaptEnabledDisabled), + string(NaptEnabledEnabled), + } +} + +func (s *NaptEnabled) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNaptEnabled(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNaptEnabled(input string) (*NaptEnabled, error) { + vals := map[string]NaptEnabled{ + "disabled": NaptEnabledDisabled, + "enabled": NaptEnabledEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NaptEnabled(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/id_packetcoredataplane.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/id_packetcoredataplane.go new file mode 100644 index 00000000000..fa40b062a0e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/id_packetcoredataplane.go @@ -0,0 +1,139 @@ +package attacheddatanetworks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreDataPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreDataPlaneId{} + +// PacketCoreDataPlaneId is a struct representing the Resource ID for a Packet Core Data Plane +type PacketCoreDataPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string + PacketCoreDataPlaneName string +} + +// NewPacketCoreDataPlaneID returns a new PacketCoreDataPlaneId struct +func NewPacketCoreDataPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string) PacketCoreDataPlaneId { + return PacketCoreDataPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + PacketCoreDataPlaneName: packetCoreDataPlaneName, + } +} + +// ParsePacketCoreDataPlaneID parses 'input' into a PacketCoreDataPlaneId +func ParsePacketCoreDataPlaneID(input string) (*PacketCoreDataPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreDataPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreDataPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreDataPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreDataPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreDataPlaneIDInsensitively(input string) (*PacketCoreDataPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreDataPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreDataPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreDataPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + if id.PacketCoreDataPlaneName, ok = input.Parsed["packetCoreDataPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreDataPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreDataPlaneID checks that 'input' can be parsed as a Packet Core Data Plane ID +func ValidatePacketCoreDataPlaneID(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 := ParsePacketCoreDataPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Data Plane ID +func (id PacketCoreDataPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s/packetCoreDataPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName, id.PacketCoreDataPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Data Plane ID +func (id PacketCoreDataPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + resourceids.StaticSegment("staticPacketCoreDataPlanes", "packetCoreDataPlanes", "packetCoreDataPlanes"), + resourceids.UserSpecifiedSegment("packetCoreDataPlaneName", "packetCoreDataPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Data Plane ID +func (id PacketCoreDataPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + fmt.Sprintf("Packet Core Data Plane Name: %q", id.PacketCoreDataPlaneName), + } + return fmt.Sprintf("Packet Core Data Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/id_packetcoredataplane_test.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/id_packetcoredataplane_test.go new file mode 100644 index 00000000000..7a0f73e3c84 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/id_packetcoredataplane_test.go @@ -0,0 +1,327 @@ +package attacheddatanetworks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreDataPlaneId{} + +func TestNewPacketCoreDataPlaneID(t *testing.T) { + id := NewPacketCoreDataPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } + + if id.PacketCoreDataPlaneName != "packetCoreDataPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreDataPlaneName'", id.PacketCoreDataPlaneName, "packetCoreDataPlaneValue") + } +} + +func TestFormatPacketCoreDataPlaneID(t *testing.T) { + actual := NewPacketCoreDataPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreDataPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreDataPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue", + Expected: &PacketCoreDataPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + PacketCoreDataPlaneName: "packetCoreDataPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreDataPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.PacketCoreDataPlaneName != v.Expected.PacketCoreDataPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreDataPlaneName", v.Expected.PacketCoreDataPlaneName, actual.PacketCoreDataPlaneName) + } + + } +} + +func TestParsePacketCoreDataPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreDataPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue", + Expected: &PacketCoreDataPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + PacketCoreDataPlaneName: "packetCoreDataPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS/pAcKeTcOrEdAtApLaNeVaLuE", + Expected: &PacketCoreDataPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + PacketCoreDataPlaneName: "pAcKeTcOrEdAtApLaNeVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS/pAcKeTcOrEdAtApLaNeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreDataPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.PacketCoreDataPlaneName != v.Expected.PacketCoreDataPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreDataPlaneName", v.Expected.PacketCoreDataPlaneName, actual.PacketCoreDataPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreDataPlaneId(t *testing.T) { + segments := PacketCoreDataPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreDataPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/method_listbypacketcoredataplane.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/method_listbypacketcoredataplane.go new file mode 100644 index 00000000000..cf26d663658 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/method_listbypacketcoredataplane.go @@ -0,0 +1,91 @@ +package attacheddatanetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByPacketCoreDataPlaneOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AttachedDataNetwork +} + +type ListByPacketCoreDataPlaneCompleteResult struct { + LatestHttpResponse *http.Response + Items []AttachedDataNetwork +} + +// ListByPacketCoreDataPlane ... +func (c AttachedDataNetworksClient) ListByPacketCoreDataPlane(ctx context.Context, id PacketCoreDataPlaneId) (result ListByPacketCoreDataPlaneOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/attachedDataNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AttachedDataNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByPacketCoreDataPlaneComplete retrieves all the results into a single object +func (c AttachedDataNetworksClient) ListByPacketCoreDataPlaneComplete(ctx context.Context, id PacketCoreDataPlaneId) (ListByPacketCoreDataPlaneCompleteResult, error) { + return c.ListByPacketCoreDataPlaneCompleteMatchingPredicate(ctx, id, AttachedDataNetworkOperationPredicate{}) +} + +// ListByPacketCoreDataPlaneCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AttachedDataNetworksClient) ListByPacketCoreDataPlaneCompleteMatchingPredicate(ctx context.Context, id PacketCoreDataPlaneId, predicate AttachedDataNetworkOperationPredicate) (result ListByPacketCoreDataPlaneCompleteResult, err error) { + items := make([]AttachedDataNetwork, 0) + + resp, err := c.ListByPacketCoreDataPlane(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByPacketCoreDataPlaneCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_attacheddatanetwork.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_attacheddatanetwork.go new file mode 100644 index 00000000000..3b912f4a880 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_attacheddatanetwork.go @@ -0,0 +1,18 @@ +package attacheddatanetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetwork struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties AttachedDataNetworkPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_attacheddatanetworkpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_attacheddatanetworkpropertiesformat.go new file mode 100644 index 00000000000..623456e5f2f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_attacheddatanetworkpropertiesformat.go @@ -0,0 +1,13 @@ +package attacheddatanetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetworkPropertiesFormat struct { + DnsAddresses []string `json:"dnsAddresses"` + NaptConfiguration *NaptConfiguration `json:"naptConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + UserEquipmentAddressPoolPrefix *[]string `json:"userEquipmentAddressPoolPrefix,omitempty"` + UserEquipmentStaticAddressPoolPrefix *[]string `json:"userEquipmentStaticAddressPoolPrefix,omitempty"` + UserPlaneDataInterface InterfaceProperties `json:"userPlaneDataInterface"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_interfaceproperties.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_interfaceproperties.go new file mode 100644 index 00000000000..e0a19967633 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_interfaceproperties.go @@ -0,0 +1,14 @@ +package attacheddatanetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InterfaceProperties struct { + BfdIPv4Endpoints *[]string `json:"bfdIpv4Endpoints,omitempty"` + IPv4Address *string `json:"ipv4Address,omitempty"` + IPv4AddressList *[]string `json:"ipv4AddressList,omitempty"` + IPv4Gateway *string `json:"ipv4Gateway,omitempty"` + IPv4Subnet *string `json:"ipv4Subnet,omitempty"` + Name *string `json:"name,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_naptconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_naptconfiguration.go new file mode 100644 index 00000000000..b4503dd9a0f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_naptconfiguration.go @@ -0,0 +1,12 @@ +package attacheddatanetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NaptConfiguration struct { + Enabled *NaptEnabled `json:"enabled,omitempty"` + PinholeLimits *int64 `json:"pinholeLimits,omitempty"` + PinholeTimeouts *PinholeTimeouts `json:"pinholeTimeouts,omitempty"` + PortRange *PortRange `json:"portRange,omitempty"` + PortReuseHoldTime *PortReuseHoldTimes `json:"portReuseHoldTime,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_pinholetimeouts.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_pinholetimeouts.go new file mode 100644 index 00000000000..dd729ff1c49 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_pinholetimeouts.go @@ -0,0 +1,10 @@ +package attacheddatanetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PinholeTimeouts struct { + Icmp *int64 `json:"icmp,omitempty"` + Tcp *int64 `json:"tcp,omitempty"` + Udp *int64 `json:"udp,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_portrange.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_portrange.go new file mode 100644 index 00000000000..b7cc962ac95 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_portrange.go @@ -0,0 +1,9 @@ +package attacheddatanetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PortRange struct { + MaxPort *int64 `json:"maxPort,omitempty"` + MinPort *int64 `json:"minPort,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_portreuseholdtimes.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_portreuseholdtimes.go new file mode 100644 index 00000000000..b37a195de8d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/model_portreuseholdtimes.go @@ -0,0 +1,9 @@ +package attacheddatanetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PortReuseHoldTimes struct { + Tcp *int64 `json:"tcp,omitempty"` + Udp *int64 `json:"udp,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/predicates.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/predicates.go new file mode 100644 index 00000000000..061b9c0fb30 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/predicates.go @@ -0,0 +1,32 @@ +package attacheddatanetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AttachedDataNetworkOperationPredicate) Matches(input AttachedDataNetwork) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/version.go b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/version.go new file mode 100644 index 00000000000..91753d1693c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks/version.go @@ -0,0 +1,12 @@ +package attacheddatanetworks + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/attacheddatanetworks/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/client.go b/resource-manager/mobilenetwork/2024-04-01/client.go new file mode 100644 index 00000000000..19fa2445530 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/client.go @@ -0,0 +1,298 @@ +package v2024_04_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/attacheddatanetwork" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/attacheddatanetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/datanetwork" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/datanetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/extendedueinformation" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/mobilenetwork" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/mobilenetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcaptures" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/routinginfo" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/service" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/services" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/sim" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simgroup" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simgroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simpolicy" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/sims" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/site" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/sites" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/slice" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/slices" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/ueinformationlist" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AttachedDataNetwork *attacheddatanetwork.AttachedDataNetworkClient + AttachedDataNetworks *attacheddatanetworks.AttachedDataNetworksClient + DataNetwork *datanetwork.DataNetworkClient + DataNetworks *datanetworks.DataNetworksClient + DiagnosticsPackages *diagnosticspackages.DiagnosticsPackagesClient + ExtendedUeInformation *extendedueinformation.ExtendedUeInformationClient + MobileNetwork *mobilenetwork.MobileNetworkClient + MobileNetworks *mobilenetworks.MobileNetworksClient + PacketCaptures *packetcaptures.PacketCapturesClient + PacketCoreControlPlane *packetcorecontrolplane.PacketCoreControlPlaneClient + PacketCoreControlPlaneCollectDiagnosticsPackage *packetcorecontrolplanecollectdiagnosticspackage.PacketCoreControlPlaneCollectDiagnosticsPackageClient + PacketCoreControlPlaneReinstall *packetcorecontrolplanereinstall.PacketCoreControlPlaneReinstallClient + PacketCoreControlPlaneRollback *packetcorecontrolplanerollback.PacketCoreControlPlaneRollbackClient + PacketCoreControlPlaneVersion *packetcorecontrolplaneversion.PacketCoreControlPlaneVersionClient + PacketCoreControlPlanes *packetcorecontrolplanes.PacketCoreControlPlanesClient + PacketCoreDataPlane *packetcoredataplane.PacketCoreDataPlaneClient + PacketCoreDataPlanes *packetcoredataplanes.PacketCoreDataPlanesClient + RoutingInfo *routinginfo.RoutingInfoClient + SIM *sim.SIMClient + SIMGroup *simgroup.SIMGroupClient + SIMGroups *simgroups.SIMGroupsClient + SIMPolicies *simpolicies.SIMPoliciesClient + SIMPolicy *simpolicy.SIMPolicyClient + SIMs *sims.SIMsClient + Service *service.ServiceClient + Services *services.ServicesClient + Site *site.SiteClient + Sites *sites.SitesClient + Slice *slice.SliceClient + Slices *slices.SlicesClient + UeInformationList *ueinformationlist.UeInformationListClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + attachedDataNetworkClient, err := attacheddatanetwork.NewAttachedDataNetworkClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AttachedDataNetwork client: %+v", err) + } + configureFunc(attachedDataNetworkClient.Client) + + attachedDataNetworksClient, err := attacheddatanetworks.NewAttachedDataNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AttachedDataNetworks client: %+v", err) + } + configureFunc(attachedDataNetworksClient.Client) + + dataNetworkClient, err := datanetwork.NewDataNetworkClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataNetwork client: %+v", err) + } + configureFunc(dataNetworkClient.Client) + + dataNetworksClient, err := datanetworks.NewDataNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataNetworks client: %+v", err) + } + configureFunc(dataNetworksClient.Client) + + diagnosticsPackagesClient, err := diagnosticspackages.NewDiagnosticsPackagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DiagnosticsPackages client: %+v", err) + } + configureFunc(diagnosticsPackagesClient.Client) + + extendedUeInformationClient, err := extendedueinformation.NewExtendedUeInformationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExtendedUeInformation client: %+v", err) + } + configureFunc(extendedUeInformationClient.Client) + + mobileNetworkClient, err := mobilenetwork.NewMobileNetworkClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MobileNetwork client: %+v", err) + } + configureFunc(mobileNetworkClient.Client) + + mobileNetworksClient, err := mobilenetworks.NewMobileNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MobileNetworks client: %+v", err) + } + configureFunc(mobileNetworksClient.Client) + + packetCapturesClient, err := packetcaptures.NewPacketCapturesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCaptures client: %+v", err) + } + configureFunc(packetCapturesClient.Client) + + packetCoreControlPlaneClient, err := packetcorecontrolplane.NewPacketCoreControlPlaneClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCoreControlPlane client: %+v", err) + } + configureFunc(packetCoreControlPlaneClient.Client) + + packetCoreControlPlaneCollectDiagnosticsPackageClient, err := packetcorecontrolplanecollectdiagnosticspackage.NewPacketCoreControlPlaneCollectDiagnosticsPackageClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCoreControlPlaneCollectDiagnosticsPackage client: %+v", err) + } + configureFunc(packetCoreControlPlaneCollectDiagnosticsPackageClient.Client) + + packetCoreControlPlaneReinstallClient, err := packetcorecontrolplanereinstall.NewPacketCoreControlPlaneReinstallClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCoreControlPlaneReinstall client: %+v", err) + } + configureFunc(packetCoreControlPlaneReinstallClient.Client) + + packetCoreControlPlaneRollbackClient, err := packetcorecontrolplanerollback.NewPacketCoreControlPlaneRollbackClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCoreControlPlaneRollback client: %+v", err) + } + configureFunc(packetCoreControlPlaneRollbackClient.Client) + + packetCoreControlPlaneVersionClient, err := packetcorecontrolplaneversion.NewPacketCoreControlPlaneVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCoreControlPlaneVersion client: %+v", err) + } + configureFunc(packetCoreControlPlaneVersionClient.Client) + + packetCoreControlPlanesClient, err := packetcorecontrolplanes.NewPacketCoreControlPlanesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCoreControlPlanes client: %+v", err) + } + configureFunc(packetCoreControlPlanesClient.Client) + + packetCoreDataPlaneClient, err := packetcoredataplane.NewPacketCoreDataPlaneClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCoreDataPlane client: %+v", err) + } + configureFunc(packetCoreDataPlaneClient.Client) + + packetCoreDataPlanesClient, err := packetcoredataplanes.NewPacketCoreDataPlanesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCoreDataPlanes client: %+v", err) + } + configureFunc(packetCoreDataPlanesClient.Client) + + routingInfoClient, err := routinginfo.NewRoutingInfoClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RoutingInfo client: %+v", err) + } + configureFunc(routingInfoClient.Client) + + sIMClient, err := sim.NewSIMClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SIM client: %+v", err) + } + configureFunc(sIMClient.Client) + + sIMGroupClient, err := simgroup.NewSIMGroupClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SIMGroup client: %+v", err) + } + configureFunc(sIMGroupClient.Client) + + sIMGroupsClient, err := simgroups.NewSIMGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SIMGroups client: %+v", err) + } + configureFunc(sIMGroupsClient.Client) + + sIMPoliciesClient, err := simpolicies.NewSIMPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SIMPolicies client: %+v", err) + } + configureFunc(sIMPoliciesClient.Client) + + sIMPolicyClient, err := simpolicy.NewSIMPolicyClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SIMPolicy client: %+v", err) + } + configureFunc(sIMPolicyClient.Client) + + sIMsClient, err := sims.NewSIMsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SIMs client: %+v", err) + } + configureFunc(sIMsClient.Client) + + serviceClient, err := service.NewServiceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Service client: %+v", err) + } + configureFunc(serviceClient.Client) + + servicesClient, err := services.NewServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Services client: %+v", err) + } + configureFunc(servicesClient.Client) + + siteClient, err := site.NewSiteClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Site client: %+v", err) + } + configureFunc(siteClient.Client) + + sitesClient, err := sites.NewSitesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Sites client: %+v", err) + } + configureFunc(sitesClient.Client) + + sliceClient, err := slice.NewSliceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Slice client: %+v", err) + } + configureFunc(sliceClient.Client) + + slicesClient, err := slices.NewSlicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Slices client: %+v", err) + } + configureFunc(slicesClient.Client) + + ueInformationListClient, err := ueinformationlist.NewUeInformationListClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building UeInformationList client: %+v", err) + } + configureFunc(ueInformationListClient.Client) + + return &Client{ + AttachedDataNetwork: attachedDataNetworkClient, + AttachedDataNetworks: attachedDataNetworksClient, + DataNetwork: dataNetworkClient, + DataNetworks: dataNetworksClient, + DiagnosticsPackages: diagnosticsPackagesClient, + ExtendedUeInformation: extendedUeInformationClient, + MobileNetwork: mobileNetworkClient, + MobileNetworks: mobileNetworksClient, + PacketCaptures: packetCapturesClient, + PacketCoreControlPlane: packetCoreControlPlaneClient, + PacketCoreControlPlaneCollectDiagnosticsPackage: packetCoreControlPlaneCollectDiagnosticsPackageClient, + PacketCoreControlPlaneReinstall: packetCoreControlPlaneReinstallClient, + PacketCoreControlPlaneRollback: packetCoreControlPlaneRollbackClient, + PacketCoreControlPlaneVersion: packetCoreControlPlaneVersionClient, + PacketCoreControlPlanes: packetCoreControlPlanesClient, + PacketCoreDataPlane: packetCoreDataPlaneClient, + PacketCoreDataPlanes: packetCoreDataPlanesClient, + RoutingInfo: routingInfoClient, + SIM: sIMClient, + SIMGroup: sIMGroupClient, + SIMGroups: sIMGroupsClient, + SIMPolicies: sIMPoliciesClient, + SIMPolicy: sIMPolicyClient, + SIMs: sIMsClient, + Service: serviceClient, + Services: servicesClient, + Site: siteClient, + Sites: sitesClient, + Slice: sliceClient, + Slices: slicesClient, + UeInformationList: ueInformationListClient, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/README.md b/resource-manager/mobilenetwork/2024-04-01/datanetwork/README.md new file mode 100644 index 00000000000..a21f459253b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/datanetwork` Documentation + +The `datanetwork` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/datanetwork" +``` + + +### Client Initialization + +```go +client := datanetwork.NewDataNetworkClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataNetworkClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := datanetwork.NewDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "dataNetworkValue") + +payload := datanetwork.DataNetwork{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataNetworkClient.Delete` + +```go +ctx := context.TODO() +id := datanetwork.NewDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "dataNetworkValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataNetworkClient.Get` + +```go +ctx := context.TODO() +id := datanetwork.NewDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "dataNetworkValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataNetworkClient.UpdateTags` + +```go +ctx := context.TODO() +id := datanetwork.NewDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "dataNetworkValue") + +payload := datanetwork.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/client.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/client.go new file mode 100644 index 00000000000..24738bf5e57 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/client.go @@ -0,0 +1,26 @@ +package datanetwork + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetworkClient struct { + Client *resourcemanager.Client +} + +func NewDataNetworkClientWithBaseURI(sdkApi sdkEnv.Api) (*DataNetworkClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "datanetwork", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataNetworkClient: %+v", err) + } + + return &DataNetworkClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/constants.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/constants.go new file mode 100644 index 00000000000..1d39aaeaea5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/constants.go @@ -0,0 +1,66 @@ +package datanetwork + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/id_datanetwork.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/id_datanetwork.go new file mode 100644 index 00000000000..0584ffc18be --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/id_datanetwork.go @@ -0,0 +1,139 @@ +package datanetwork + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DataNetworkId{}) +} + +var _ resourceids.ResourceId = &DataNetworkId{} + +// DataNetworkId is a struct representing the Resource ID for a Data Network +type DataNetworkId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string + DataNetworkName string +} + +// NewDataNetworkID returns a new DataNetworkId struct +func NewDataNetworkID(subscriptionId string, resourceGroupName string, mobileNetworkName string, dataNetworkName string) DataNetworkId { + return DataNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + DataNetworkName: dataNetworkName, + } +} + +// ParseDataNetworkID parses 'input' into a DataNetworkId +func ParseDataNetworkID(input string) (*DataNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataNetworkIDInsensitively parses 'input' case-insensitively into a DataNetworkId +// note: this method should only be used for API response data and not user input +func ParseDataNetworkIDInsensitively(input string) (*DataNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + if id.DataNetworkName, ok = input.Parsed["dataNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataNetworkName", input) + } + + return nil +} + +// ValidateDataNetworkID checks that 'input' can be parsed as a Data Network ID +func ValidateDataNetworkID(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 := ParseDataNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Network ID +func (id DataNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s/dataNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName, id.DataNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Network ID +func (id DataNetworkId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + resourceids.StaticSegment("staticDataNetworks", "dataNetworks", "dataNetworks"), + resourceids.UserSpecifiedSegment("dataNetworkName", "dataNetworkValue"), + } +} + +// String returns a human-readable description of this Data Network ID +func (id DataNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + fmt.Sprintf("Data Network Name: %q", id.DataNetworkName), + } + return fmt.Sprintf("Data Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/id_datanetwork_test.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/id_datanetwork_test.go new file mode 100644 index 00000000000..c5933945b85 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/id_datanetwork_test.go @@ -0,0 +1,327 @@ +package datanetwork + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataNetworkId{} + +func TestNewDataNetworkID(t *testing.T) { + id := NewDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "dataNetworkValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } + + if id.DataNetworkName != "dataNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'DataNetworkName'", id.DataNetworkName, "dataNetworkValue") + } +} + +func TestFormatDataNetworkID(t *testing.T) { + actual := NewDataNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "dataNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/dataNetworks/dataNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/dataNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/dataNetworks/dataNetworkValue", + Expected: &DataNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + DataNetworkName: "dataNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/dataNetworks/dataNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataNetworkID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.DataNetworkName != v.Expected.DataNetworkName { + t.Fatalf("Expected %q but got %q for DataNetworkName", v.Expected.DataNetworkName, actual.DataNetworkName) + } + + } +} + +func TestParseDataNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/dataNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/dAtAnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/dataNetworks/dataNetworkValue", + Expected: &DataNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + DataNetworkName: "dataNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/dataNetworks/dataNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/dAtAnEtWoRkS/dAtAnEtWoRkVaLuE", + Expected: &DataNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + DataNetworkName: "dAtAnEtWoRkVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/dAtAnEtWoRkS/dAtAnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataNetworkIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.DataNetworkName != v.Expected.DataNetworkName { + t.Fatalf("Expected %q but got %q for DataNetworkName", v.Expected.DataNetworkName, actual.DataNetworkName) + } + + } +} + +func TestSegmentsForDataNetworkId(t *testing.T) { + segments := DataNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_createorupdate.go new file mode 100644 index 00000000000..d733b258afb --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_createorupdate.go @@ -0,0 +1,75 @@ +package datanetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataNetwork +} + +// CreateOrUpdate ... +func (c DataNetworkClient) CreateOrUpdate(ctx context.Context, id DataNetworkId, input DataNetwork) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DataNetworkClient) CreateOrUpdateThenPoll(ctx context.Context, id DataNetworkId, input DataNetwork) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_delete.go new file mode 100644 index 00000000000..13637f6c701 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_delete.go @@ -0,0 +1,71 @@ +package datanetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DataNetworkClient) Delete(ctx context.Context, id DataNetworkId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DataNetworkClient) DeleteThenPoll(ctx context.Context, id DataNetworkId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_get.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_get.go new file mode 100644 index 00000000000..54ae2abcc3b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_get.go @@ -0,0 +1,54 @@ +package datanetwork + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataNetwork +} + +// Get ... +func (c DataNetworkClient) Get(ctx context.Context, id DataNetworkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DataNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_updatetags.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_updatetags.go new file mode 100644 index 00000000000..dff4c238fc8 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/method_updatetags.go @@ -0,0 +1,58 @@ +package datanetwork + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataNetwork +} + +// UpdateTags ... +func (c DataNetworkClient) UpdateTags(ctx context.Context, id DataNetworkId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DataNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/model_datanetwork.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/model_datanetwork.go new file mode 100644 index 00000000000..0dc78bae044 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/model_datanetwork.go @@ -0,0 +1,18 @@ +package datanetwork + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetwork struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DataNetworkPropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/model_datanetworkpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/model_datanetworkpropertiesformat.go new file mode 100644 index 00000000000..dcc198607b0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/model_datanetworkpropertiesformat.go @@ -0,0 +1,9 @@ +package datanetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetworkPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/model_tagsobject.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/model_tagsobject.go new file mode 100644 index 00000000000..e6bbc608c05 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/model_tagsobject.go @@ -0,0 +1,8 @@ +package datanetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetwork/version.go b/resource-manager/mobilenetwork/2024-04-01/datanetwork/version.go new file mode 100644 index 00000000000..d68d0d6ca07 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetwork/version.go @@ -0,0 +1,12 @@ +package datanetwork + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/datanetwork/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/README.md b/resource-manager/mobilenetwork/2024-04-01/datanetworks/README.md new file mode 100644 index 00000000000..da2672807a3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/datanetworks` Documentation + +The `datanetworks` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/datanetworks" +``` + + +### Client Initialization + +```go +client := datanetworks.NewDataNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataNetworksClient.ListByMobileNetwork` + +```go +ctx := context.TODO() +id := datanetworks.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +// alternatively `client.ListByMobileNetwork(ctx, id)` can be used to do batched pagination +items, err := client.ListByMobileNetworkComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/client.go b/resource-manager/mobilenetwork/2024-04-01/datanetworks/client.go new file mode 100644 index 00000000000..a3e1366086d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/client.go @@ -0,0 +1,26 @@ +package datanetworks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetworksClient struct { + Client *resourcemanager.Client +} + +func NewDataNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*DataNetworksClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "datanetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataNetworksClient: %+v", err) + } + + return &DataNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/constants.go b/resource-manager/mobilenetwork/2024-04-01/datanetworks/constants.go new file mode 100644 index 00000000000..4e8c07fe723 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/constants.go @@ -0,0 +1,66 @@ +package datanetworks + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/id_mobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/datanetworks/id_mobilenetwork.go new file mode 100644 index 00000000000..14777643b61 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/id_mobilenetwork.go @@ -0,0 +1,130 @@ +package datanetworks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MobileNetworkId{}) +} + +var _ resourceids.ResourceId = &MobileNetworkId{} + +// MobileNetworkId is a struct representing the Resource ID for a Mobile Network +type MobileNetworkId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string +} + +// NewMobileNetworkID returns a new MobileNetworkId struct +func NewMobileNetworkID(subscriptionId string, resourceGroupName string, mobileNetworkName string) MobileNetworkId { + return MobileNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + } +} + +// ParseMobileNetworkID parses 'input' into a MobileNetworkId +func ParseMobileNetworkID(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMobileNetworkIDInsensitively parses 'input' case-insensitively into a MobileNetworkId +// note: this method should only be used for API response data and not user input +func ParseMobileNetworkIDInsensitively(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MobileNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + return nil +} + +// ValidateMobileNetworkID checks that 'input' can be parsed as a Mobile Network ID +func ValidateMobileNetworkID(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 := ParseMobileNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mobile Network ID +func (id MobileNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mobile Network ID +func (id MobileNetworkId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + } +} + +// String returns a human-readable description of this Mobile Network ID +func (id MobileNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + } + return fmt.Sprintf("Mobile Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/id_mobilenetwork_test.go b/resource-manager/mobilenetwork/2024-04-01/datanetworks/id_mobilenetwork_test.go new file mode 100644 index 00000000000..df41f9d8566 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/id_mobilenetwork_test.go @@ -0,0 +1,282 @@ +package datanetworks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MobileNetworkId{} + +func TestNewMobileNetworkID(t *testing.T) { + id := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } +} + +func TestFormatMobileNetworkID(t *testing.T) { + actual := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMobileNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestParseMobileNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestSegmentsForMobileNetworkId(t *testing.T) { + segments := MobileNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MobileNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/method_listbymobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/datanetworks/method_listbymobilenetwork.go new file mode 100644 index 00000000000..a309afbd95e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/method_listbymobilenetwork.go @@ -0,0 +1,91 @@ +package datanetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByMobileNetworkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataNetwork +} + +type ListByMobileNetworkCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataNetwork +} + +// ListByMobileNetwork ... +func (c DataNetworksClient) ListByMobileNetwork(ctx context.Context, id MobileNetworkId) (result ListByMobileNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dataNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DataNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByMobileNetworkComplete retrieves all the results into a single object +func (c DataNetworksClient) ListByMobileNetworkComplete(ctx context.Context, id MobileNetworkId) (ListByMobileNetworkCompleteResult, error) { + return c.ListByMobileNetworkCompleteMatchingPredicate(ctx, id, DataNetworkOperationPredicate{}) +} + +// ListByMobileNetworkCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataNetworksClient) ListByMobileNetworkCompleteMatchingPredicate(ctx context.Context, id MobileNetworkId, predicate DataNetworkOperationPredicate) (result ListByMobileNetworkCompleteResult, err error) { + items := make([]DataNetwork, 0) + + resp, err := c.ListByMobileNetwork(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByMobileNetworkCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/model_datanetwork.go b/resource-manager/mobilenetwork/2024-04-01/datanetworks/model_datanetwork.go new file mode 100644 index 00000000000..de5aa15df36 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/model_datanetwork.go @@ -0,0 +1,18 @@ +package datanetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetwork struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DataNetworkPropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/model_datanetworkpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/datanetworks/model_datanetworkpropertiesformat.go new file mode 100644 index 00000000000..7eb051d89d1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/model_datanetworkpropertiesformat.go @@ -0,0 +1,9 @@ +package datanetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetworkPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/predicates.go b/resource-manager/mobilenetwork/2024-04-01/datanetworks/predicates.go new file mode 100644 index 00000000000..cea221f8730 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/predicates.go @@ -0,0 +1,32 @@ +package datanetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p DataNetworkOperationPredicate) Matches(input DataNetwork) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/datanetworks/version.go b/resource-manager/mobilenetwork/2024-04-01/datanetworks/version.go new file mode 100644 index 00000000000..d398bb57e42 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/datanetworks/version.go @@ -0,0 +1,12 @@ +package datanetworks + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/datanetworks/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/README.md b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/README.md new file mode 100644 index 00000000000..a8291332d00 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/README.md @@ -0,0 +1,77 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages` Documentation + +The `diagnosticspackages` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages" +``` + + +### Client Initialization + +```go +client := diagnosticspackages.NewDiagnosticsPackagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DiagnosticsPackagesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := diagnosticspackages.NewDiagnosticsPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "diagnosticsPackageValue") + +if err := client.CreateOrUpdateThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiagnosticsPackagesClient.Delete` + +```go +ctx := context.TODO() +id := diagnosticspackages.NewDiagnosticsPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "diagnosticsPackageValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DiagnosticsPackagesClient.Get` + +```go +ctx := context.TODO() +id := diagnosticspackages.NewDiagnosticsPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "diagnosticsPackageValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsPackagesClient.ListByPacketCoreControlPlane` + +```go +ctx := context.TODO() +id := diagnosticspackages.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +// alternatively `client.ListByPacketCoreControlPlane(ctx, id)` can be used to do batched pagination +items, err := client.ListByPacketCoreControlPlaneComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/client.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/client.go new file mode 100644 index 00000000000..8769a6d4036 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/client.go @@ -0,0 +1,26 @@ +package diagnosticspackages + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsPackagesClient struct { + Client *resourcemanager.Client +} + +func NewDiagnosticsPackagesClientWithBaseURI(sdkApi sdkEnv.Api) (*DiagnosticsPackagesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "diagnosticspackages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiagnosticsPackagesClient: %+v", err) + } + + return &DiagnosticsPackagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/constants.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/constants.go new file mode 100644 index 00000000000..186278cd759 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/constants.go @@ -0,0 +1,113 @@ +package diagnosticspackages + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsPackageStatus string + +const ( + DiagnosticsPackageStatusCollected DiagnosticsPackageStatus = "Collected" + DiagnosticsPackageStatusCollecting DiagnosticsPackageStatus = "Collecting" + DiagnosticsPackageStatusError DiagnosticsPackageStatus = "Error" + DiagnosticsPackageStatusNotStarted DiagnosticsPackageStatus = "NotStarted" +) + +func PossibleValuesForDiagnosticsPackageStatus() []string { + return []string{ + string(DiagnosticsPackageStatusCollected), + string(DiagnosticsPackageStatusCollecting), + string(DiagnosticsPackageStatusError), + string(DiagnosticsPackageStatusNotStarted), + } +} + +func (s *DiagnosticsPackageStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiagnosticsPackageStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiagnosticsPackageStatus(input string) (*DiagnosticsPackageStatus, error) { + vals := map[string]DiagnosticsPackageStatus{ + "collected": DiagnosticsPackageStatusCollected, + "collecting": DiagnosticsPackageStatusCollecting, + "error": DiagnosticsPackageStatusError, + "notstarted": DiagnosticsPackageStatusNotStarted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiagnosticsPackageStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_diagnosticspackage.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_diagnosticspackage.go new file mode 100644 index 00000000000..664519d698b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_diagnosticspackage.go @@ -0,0 +1,139 @@ +package diagnosticspackages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DiagnosticsPackageId{}) +} + +var _ resourceids.ResourceId = &DiagnosticsPackageId{} + +// DiagnosticsPackageId is a struct representing the Resource ID for a Diagnostics Package +type DiagnosticsPackageId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string + DiagnosticsPackageName string +} + +// NewDiagnosticsPackageID returns a new DiagnosticsPackageId struct +func NewDiagnosticsPackageID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string, diagnosticsPackageName string) DiagnosticsPackageId { + return DiagnosticsPackageId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + DiagnosticsPackageName: diagnosticsPackageName, + } +} + +// ParseDiagnosticsPackageID parses 'input' into a DiagnosticsPackageId +func ParseDiagnosticsPackageID(input string) (*DiagnosticsPackageId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticsPackageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticsPackageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticsPackageIDInsensitively parses 'input' case-insensitively into a DiagnosticsPackageId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticsPackageIDInsensitively(input string) (*DiagnosticsPackageId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticsPackageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticsPackageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticsPackageId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + if id.DiagnosticsPackageName, ok = input.Parsed["diagnosticsPackageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticsPackageName", input) + } + + return nil +} + +// ValidateDiagnosticsPackageID checks that 'input' can be parsed as a Diagnostics Package ID +func ValidateDiagnosticsPackageID(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 := ParseDiagnosticsPackageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostics Package ID +func (id DiagnosticsPackageId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s/diagnosticsPackages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName, id.DiagnosticsPackageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostics Package ID +func (id DiagnosticsPackageId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + resourceids.StaticSegment("staticDiagnosticsPackages", "diagnosticsPackages", "diagnosticsPackages"), + resourceids.UserSpecifiedSegment("diagnosticsPackageName", "diagnosticsPackageValue"), + } +} + +// String returns a human-readable description of this Diagnostics Package ID +func (id DiagnosticsPackageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + fmt.Sprintf("Diagnostics Package Name: %q", id.DiagnosticsPackageName), + } + return fmt.Sprintf("Diagnostics Package (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_diagnosticspackage_test.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_diagnosticspackage_test.go new file mode 100644 index 00000000000..01cfdf47874 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_diagnosticspackage_test.go @@ -0,0 +1,327 @@ +package diagnosticspackages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DiagnosticsPackageId{} + +func TestNewDiagnosticsPackageID(t *testing.T) { + id := NewDiagnosticsPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "diagnosticsPackageValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } + + if id.DiagnosticsPackageName != "diagnosticsPackageValue" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticsPackageName'", id.DiagnosticsPackageName, "diagnosticsPackageValue") + } +} + +func TestFormatDiagnosticsPackageID(t *testing.T) { + actual := NewDiagnosticsPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "diagnosticsPackageValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/diagnosticsPackages/diagnosticsPackageValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticsPackageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticsPackageId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/diagnosticsPackages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/diagnosticsPackages/diagnosticsPackageValue", + Expected: &DiagnosticsPackageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + DiagnosticsPackageName: "diagnosticsPackageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/diagnosticsPackages/diagnosticsPackageValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticsPackageID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.DiagnosticsPackageName != v.Expected.DiagnosticsPackageName { + t.Fatalf("Expected %q but got %q for DiagnosticsPackageName", v.Expected.DiagnosticsPackageName, actual.DiagnosticsPackageName) + } + + } +} + +func TestParseDiagnosticsPackageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticsPackageId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/diagnosticsPackages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/dIaGnOsTiCsPaCkAgEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/diagnosticsPackages/diagnosticsPackageValue", + Expected: &DiagnosticsPackageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + DiagnosticsPackageName: "diagnosticsPackageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/diagnosticsPackages/diagnosticsPackageValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/dIaGnOsTiCsPaCkAgEs/dIaGnOsTiCsPaCkAgEvAlUe", + Expected: &DiagnosticsPackageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + DiagnosticsPackageName: "dIaGnOsTiCsPaCkAgEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/dIaGnOsTiCsPaCkAgEs/dIaGnOsTiCsPaCkAgEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticsPackageIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.DiagnosticsPackageName != v.Expected.DiagnosticsPackageName { + t.Fatalf("Expected %q but got %q for DiagnosticsPackageName", v.Expected.DiagnosticsPackageName, actual.DiagnosticsPackageName) + } + + } +} + +func TestSegmentsForDiagnosticsPackageId(t *testing.T) { + segments := DiagnosticsPackageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticsPackageId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_packetcorecontrolplane.go new file mode 100644 index 00000000000..117e98de30a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_packetcorecontrolplane.go @@ -0,0 +1,130 @@ +package diagnosticspackages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +// PacketCoreControlPlaneId is a struct representing the Resource ID for a Packet Core Control Plane +type PacketCoreControlPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string +} + +// NewPacketCoreControlPlaneID returns a new PacketCoreControlPlaneId struct +func NewPacketCoreControlPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string) PacketCoreControlPlaneId { + return PacketCoreControlPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + } +} + +// ParsePacketCoreControlPlaneID parses 'input' into a PacketCoreControlPlaneId +func ParsePacketCoreControlPlaneID(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneIDInsensitively(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneID checks that 'input' can be parsed as a Packet Core Control Plane ID +func ValidatePacketCoreControlPlaneID(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 := ParsePacketCoreControlPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + } + return fmt.Sprintf("Packet Core Control Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_packetcorecontrolplane_test.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_packetcorecontrolplane_test.go new file mode 100644 index 00000000000..59c1e4614b7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/id_packetcorecontrolplane_test.go @@ -0,0 +1,282 @@ +package diagnosticspackages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +func TestNewPacketCoreControlPlaneID(t *testing.T) { + id := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } +} + +func TestFormatPacketCoreControlPlaneID(t *testing.T) { + actual := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestParsePacketCoreControlPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneId(t *testing.T) { + segments := PacketCoreControlPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_createorupdate.go new file mode 100644 index 00000000000..f638c8d662c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_createorupdate.go @@ -0,0 +1,71 @@ +package diagnosticspackages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticsPackage +} + +// CreateOrUpdate ... +func (c DiagnosticsPackagesClient) CreateOrUpdate(ctx context.Context, id DiagnosticsPackageId) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DiagnosticsPackagesClient) CreateOrUpdateThenPoll(ctx context.Context, id DiagnosticsPackageId) error { + result, err := c.CreateOrUpdate(ctx, id) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_delete.go new file mode 100644 index 00000000000..42710fc9289 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_delete.go @@ -0,0 +1,71 @@ +package diagnosticspackages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DiagnosticsPackagesClient) Delete(ctx context.Context, id DiagnosticsPackageId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DiagnosticsPackagesClient) DeleteThenPoll(ctx context.Context, id DiagnosticsPackageId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_get.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_get.go new file mode 100644 index 00000000000..755ab1f5a11 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_get.go @@ -0,0 +1,54 @@ +package diagnosticspackages + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticsPackage +} + +// Get ... +func (c DiagnosticsPackagesClient) Get(ctx context.Context, id DiagnosticsPackageId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DiagnosticsPackage + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_listbypacketcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_listbypacketcorecontrolplane.go new file mode 100644 index 00000000000..68d24908082 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/method_listbypacketcorecontrolplane.go @@ -0,0 +1,91 @@ +package diagnosticspackages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByPacketCoreControlPlaneOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticsPackage +} + +type ListByPacketCoreControlPlaneCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiagnosticsPackage +} + +// ListByPacketCoreControlPlane ... +func (c DiagnosticsPackagesClient) ListByPacketCoreControlPlane(ctx context.Context, id PacketCoreControlPlaneId) (result ListByPacketCoreControlPlaneOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnosticsPackages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DiagnosticsPackage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByPacketCoreControlPlaneComplete retrieves all the results into a single object +func (c DiagnosticsPackagesClient) ListByPacketCoreControlPlaneComplete(ctx context.Context, id PacketCoreControlPlaneId) (ListByPacketCoreControlPlaneCompleteResult, error) { + return c.ListByPacketCoreControlPlaneCompleteMatchingPredicate(ctx, id, DiagnosticsPackageOperationPredicate{}) +} + +// ListByPacketCoreControlPlaneCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsPackagesClient) ListByPacketCoreControlPlaneCompleteMatchingPredicate(ctx context.Context, id PacketCoreControlPlaneId, predicate DiagnosticsPackageOperationPredicate) (result ListByPacketCoreControlPlaneCompleteResult, err error) { + items := make([]DiagnosticsPackage, 0) + + resp, err := c.ListByPacketCoreControlPlane(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByPacketCoreControlPlaneCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/model_diagnosticspackage.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/model_diagnosticspackage.go new file mode 100644 index 00000000000..928cbf3a42e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/model_diagnosticspackage.go @@ -0,0 +1,16 @@ +package diagnosticspackages + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsPackage struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties DiagnosticsPackagePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/model_diagnosticspackagepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/model_diagnosticspackagepropertiesformat.go new file mode 100644 index 00000000000..f1e22c4e34d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/model_diagnosticspackagepropertiesformat.go @@ -0,0 +1,10 @@ +package diagnosticspackages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsPackagePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *DiagnosticsPackageStatus `json:"status,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/predicates.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/predicates.go new file mode 100644 index 00000000000..3d751659ab0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/predicates.go @@ -0,0 +1,27 @@ +package diagnosticspackages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsPackageOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DiagnosticsPackageOperationPredicate) Matches(input DiagnosticsPackage) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/version.go b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/version.go new file mode 100644 index 00000000000..cc63d0a25d7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/diagnosticspackages/version.go @@ -0,0 +1,12 @@ +package diagnosticspackages + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/diagnosticspackages/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/README.md b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/README.md new file mode 100644 index 00000000000..baf34969865 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/extendedueinformation` Documentation + +The `extendedueinformation` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/extendedueinformation" +``` + + +### Client Initialization + +```go +client := extendedueinformation.NewExtendedUeInformationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExtendedUeInformationClient.Get` + +```go +ctx := context.TODO() +id := extendedueinformation.NewUeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "ueIdValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/client.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/client.go new file mode 100644 index 00000000000..fdc486a9414 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/client.go @@ -0,0 +1,26 @@ +package extendedueinformation + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedUeInformationClient struct { + Client *resourcemanager.Client +} + +func NewExtendedUeInformationClientWithBaseURI(sdkApi sdkEnv.Api) (*ExtendedUeInformationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "extendedueinformation", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExtendedUeInformationClient: %+v", err) + } + + return &ExtendedUeInformationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/constants.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/constants.go new file mode 100644 index 00000000000..2f8bb500bc0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/constants.go @@ -0,0 +1,233 @@ +package extendedueinformation + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PdnType string + +const ( + PdnTypeIPVFour PdnType = "IPV4" +) + +func PossibleValuesForPdnType() []string { + return []string{ + string(PdnTypeIPVFour), + } +} + +func (s *PdnType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePdnType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePdnType(input string) (*PdnType, error) { + vals := map[string]PdnType{ + "ipv4": PdnTypeIPVFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PdnType(input) + return &out, nil +} + +type RatType string + +const ( + RatTypeFiveG RatType = "5G" + RatTypeFourG RatType = "4G" +) + +func PossibleValuesForRatType() []string { + return []string{ + string(RatTypeFiveG), + string(RatTypeFourG), + } +} + +func (s *RatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRatType(input string) (*RatType, error) { + vals := map[string]RatType{ + "5g": RatTypeFiveG, + "4g": RatTypeFourG, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RatType(input) + return &out, nil +} + +type RrcEstablishmentCause string + +const ( + RrcEstablishmentCauseEmergency RrcEstablishmentCause = "Emergency" + RrcEstablishmentCauseMobileOriginatedData RrcEstablishmentCause = "MobileOriginatedData" + RrcEstablishmentCauseMobileOriginatedSignaling RrcEstablishmentCause = "MobileOriginatedSignaling" + RrcEstablishmentCauseMobileTerminatedData RrcEstablishmentCause = "MobileTerminatedData" + RrcEstablishmentCauseMobileTerminatedSignaling RrcEstablishmentCause = "MobileTerminatedSignaling" + RrcEstablishmentCauseSMS RrcEstablishmentCause = "SMS" +) + +func PossibleValuesForRrcEstablishmentCause() []string { + return []string{ + string(RrcEstablishmentCauseEmergency), + string(RrcEstablishmentCauseMobileOriginatedData), + string(RrcEstablishmentCauseMobileOriginatedSignaling), + string(RrcEstablishmentCauseMobileTerminatedData), + string(RrcEstablishmentCauseMobileTerminatedSignaling), + string(RrcEstablishmentCauseSMS), + } +} + +func (s *RrcEstablishmentCause) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRrcEstablishmentCause(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRrcEstablishmentCause(input string) (*RrcEstablishmentCause, error) { + vals := map[string]RrcEstablishmentCause{ + "emergency": RrcEstablishmentCauseEmergency, + "mobileoriginateddata": RrcEstablishmentCauseMobileOriginatedData, + "mobileoriginatedsignaling": RrcEstablishmentCauseMobileOriginatedSignaling, + "mobileterminateddata": RrcEstablishmentCauseMobileTerminatedData, + "mobileterminatedsignaling": RrcEstablishmentCauseMobileTerminatedSignaling, + "sms": RrcEstablishmentCauseSMS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RrcEstablishmentCause(input) + return &out, nil +} + +type UeState string + +const ( + UeStateConnected UeState = "Connected" + UeStateDeregistered UeState = "Deregistered" + UeStateDetached UeState = "Detached" + UeStateIdle UeState = "Idle" + UeStateUnknown UeState = "Unknown" +) + +func PossibleValuesForUeState() []string { + return []string{ + string(UeStateConnected), + string(UeStateDeregistered), + string(UeStateDetached), + string(UeStateIdle), + string(UeStateUnknown), + } +} + +func (s *UeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUeState(input string) (*UeState, error) { + vals := map[string]UeState{ + "connected": UeStateConnected, + "deregistered": UeStateDeregistered, + "detached": UeStateDetached, + "idle": UeStateIdle, + "unknown": UeStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UeState(input) + return &out, nil +} + +type UeUsageSetting string + +const ( + UeUsageSettingDataCentric UeUsageSetting = "DataCentric" + UeUsageSettingVoiceCentric UeUsageSetting = "VoiceCentric" +) + +func PossibleValuesForUeUsageSetting() []string { + return []string{ + string(UeUsageSettingDataCentric), + string(UeUsageSettingVoiceCentric), + } +} + +func (s *UeUsageSetting) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUeUsageSetting(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUeUsageSetting(input string) (*UeUsageSetting, error) { + vals := map[string]UeUsageSetting{ + "datacentric": UeUsageSettingDataCentric, + "voicecentric": UeUsageSettingVoiceCentric, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UeUsageSetting(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/id_ue.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/id_ue.go new file mode 100644 index 00000000000..e5974af151d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/id_ue.go @@ -0,0 +1,139 @@ +package extendedueinformation + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&UeId{}) +} + +var _ resourceids.ResourceId = &UeId{} + +// UeId is a struct representing the Resource ID for a Ue +type UeId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string + UeId string +} + +// NewUeID returns a new UeId struct +func NewUeID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string, ueId string) UeId { + return UeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + UeId: ueId, + } +} + +// ParseUeID parses 'input' into a UeId +func ParseUeID(input string) (*UeId, error) { + parser := resourceids.NewParserFromResourceIdType(&UeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUeIDInsensitively parses 'input' case-insensitively into a UeId +// note: this method should only be used for API response data and not user input +func ParseUeIDInsensitively(input string) (*UeId, error) { + parser := resourceids.NewParserFromResourceIdType(&UeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UeId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + if id.UeId, ok = input.Parsed["ueId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ueId", input) + } + + return nil +} + +// ValidateUeID checks that 'input' can be parsed as a Ue ID +func ValidateUeID(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 := ParseUeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Ue ID +func (id UeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s/ues/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName, id.UeId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Ue ID +func (id UeId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + resourceids.StaticSegment("staticUes", "ues", "ues"), + resourceids.UserSpecifiedSegment("ueId", "ueIdValue"), + } +} + +// String returns a human-readable description of this Ue ID +func (id UeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + fmt.Sprintf("Ue: %q", id.UeId), + } + return fmt.Sprintf("Ue (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/id_ue_test.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/id_ue_test.go new file mode 100644 index 00000000000..2c57a14beea --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/id_ue_test.go @@ -0,0 +1,327 @@ +package extendedueinformation + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &UeId{} + +func TestNewUeID(t *testing.T) { + id := NewUeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "ueIdValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } + + if id.UeId != "ueIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'UeId'", id.UeId, "ueIdValue") + } +} + +func TestFormatUeID(t *testing.T) { + actual := NewUeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "ueIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/ues/ueIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UeId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/ues", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/ues/ueIdValue", + Expected: &UeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + UeId: "ueIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/ues/ueIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUeID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.UeId != v.Expected.UeId { + t.Fatalf("Expected %q but got %q for UeId", v.Expected.UeId, actual.UeId) + } + + } +} + +func TestParseUeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UeId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/ues", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/uEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/ues/ueIdValue", + Expected: &UeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + UeId: "ueIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/ues/ueIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/uEs/uEiDvAlUe", + Expected: &UeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + UeId: "uEiDvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/uEs/uEiDvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUeIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.UeId != v.Expected.UeId { + t.Fatalf("Expected %q but got %q for UeId", v.Expected.UeId, actual.UeId) + } + + } +} + +func TestSegmentsForUeId(t *testing.T) { + segments := UeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/method_get.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/method_get.go new file mode 100644 index 00000000000..d396e955195 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/method_get.go @@ -0,0 +1,55 @@ +package extendedueinformation + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExtendedUeInfo +} + +// Get ... +func (c ExtendedUeInformationClient) Get(ctx context.Context, id UeId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extendedInformation/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExtendedUeInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ambr.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ambr.go new file mode 100644 index 00000000000..86f64146378 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ambr.go @@ -0,0 +1,9 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ambr struct { + Downlink string `json:"downlink"` + Uplink string `json:"uplink"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_amfid.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_amfid.go new file mode 100644 index 00000000000..5a2eca6101e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_amfid.go @@ -0,0 +1,10 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmfId struct { + Pointer int64 `json:"pointer"` + RegionId int64 `json:"regionId"` + SetId int64 `json:"setId"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_extendedueinfo.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_extendedueinfo.go new file mode 100644 index 00000000000..307cff6f907 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_extendedueinfo.go @@ -0,0 +1,48 @@ +package extendedueinformation + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedUeInfo struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ExtendedUeInfoProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ExtendedUeInfo{} + +func (s *ExtendedUeInfo) UnmarshalJSON(bytes []byte) error { + type alias ExtendedUeInfo + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ExtendedUeInfo: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ExtendedUeInfo into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalExtendedUeInfoPropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ExtendedUeInfo': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_extendedueinfoproperties.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_extendedueinfoproperties.go new file mode 100644 index 00000000000..50941a86ca3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_extendedueinfoproperties.go @@ -0,0 +1,61 @@ +package extendedueinformation + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedUeInfoProperties interface { +} + +// RawExtendedUeInfoPropertiesImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawExtendedUeInfoPropertiesImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalExtendedUeInfoPropertiesImplementation(input []byte) (ExtendedUeInfoProperties, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ExtendedUeInfoProperties into map[string]interface: %+v", err) + } + + value, ok := temp["ratType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "4G") { + var out UeInfo4G + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UeInfo4G: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "5G") { + var out UeInfo5G + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UeInfo5G: %+v", err) + } + return out, nil + } + + out := RawExtendedUeInfoPropertiesImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_globalrannodeid.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_globalrannodeid.go new file mode 100644 index 00000000000..6de7a8f0ffa --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_globalrannodeid.go @@ -0,0 +1,15 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GlobalRanNodeId struct { + ENbId *string `json:"eNbId,omitempty"` + GNbId *GNbId `json:"gNbId,omitempty"` + N3IwfId *string `json:"n3IwfId,omitempty"` + NgeNbId *string `json:"ngeNbId,omitempty"` + Nid *string `json:"nid,omitempty"` + PlmnId PlmnId `json:"plmnId"` + TngfId *string `json:"tngfId,omitempty"` + WagfId *string `json:"wagfId,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_gnbid.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_gnbid.go new file mode 100644 index 00000000000..bdb1d8e5f8f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_gnbid.go @@ -0,0 +1,9 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GNbId struct { + BitLength *int64 `json:"bitLength,omitempty"` + GNBValue *string `json:"gNBValue,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_guti4g.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_guti4g.go new file mode 100644 index 00000000000..319b14f9274 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_guti4g.go @@ -0,0 +1,10 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Guti4G struct { + MTmsi int64 `json:"mTmsi"` + MmeId MmeId `json:"mmeId"` + Plmn PlmnId `json:"plmn"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_guti5g.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_guti5g.go new file mode 100644 index 00000000000..61fbfd672ac --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_guti5g.go @@ -0,0 +1,10 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Guti5G struct { + AmfId AmfId `json:"amfId"` + FivegTmsi int64 `json:"fivegTmsi"` + Plmn PlmnId `json:"plmn"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_mmeid.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_mmeid.go new file mode 100644 index 00000000000..0ed7eb9b972 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_mmeid.go @@ -0,0 +1,9 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MmeId struct { + Code int64 `json:"code"` + GroupId int64 `json:"groupId"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_plmnid.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_plmnid.go new file mode 100644 index 00000000000..46d07a5ed33 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_plmnid.go @@ -0,0 +1,9 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlmnId struct { + Mcc string `json:"mcc"` + Mnc string `json:"mnc"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_snssai.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_snssai.go new file mode 100644 index 00000000000..87a113d7d1e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_snssai.go @@ -0,0 +1,9 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snssai struct { + Sd *string `json:"sd,omitempty"` + Sst int64 `json:"sst"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueconnectioninfo4g.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueconnectioninfo4g.go new file mode 100644 index 00000000000..2ba8f29ef40 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueconnectioninfo4g.go @@ -0,0 +1,35 @@ +package extendedueinformation + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeConnectionInfo4G struct { + EnbS1apId int64 `json:"enbS1apId"` + GlobalRanNodeId GlobalRanNodeId `json:"globalRanNodeId"` + LastActivityTime *string `json:"lastActivityTime,omitempty"` + LastVisitedTai *string `json:"lastVisitedTai,omitempty"` + LocationInfo *UeLocationInfo `json:"locationInfo,omitempty"` + MmeS1apId int64 `json:"mmeS1apId"` + PerUeTnla *string `json:"perUeTnla,omitempty"` + RrcEstablishmentCause RrcEstablishmentCause `json:"rrcEstablishmentCause"` + UeState UeState `json:"ueState"` + UeUsageSetting *UeUsageSetting `json:"ueUsageSetting,omitempty"` +} + +func (o *UeConnectionInfo4G) GetLastActivityTimeAsTime() (*time.Time, error) { + if o.LastActivityTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastActivityTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UeConnectionInfo4G) SetLastActivityTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastActivityTime = &formatted +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueconnectioninfo5g.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueconnectioninfo5g.go new file mode 100644 index 00000000000..64506e9b80a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueconnectioninfo5g.go @@ -0,0 +1,36 @@ +package extendedueinformation + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeConnectionInfo5G struct { + AllowedNssai *[]Snssai `json:"allowedNssai,omitempty"` + AmfUeNgapId int64 `json:"amfUeNgapId"` + GlobalRanNodeId GlobalRanNodeId `json:"globalRanNodeId"` + LastActivityTime *string `json:"lastActivityTime,omitempty"` + LastVisitedTai *string `json:"lastVisitedTai,omitempty"` + LocationInfo *UeLocationInfo `json:"locationInfo,omitempty"` + PerUeTnla *string `json:"perUeTnla,omitempty"` + RanUeNgapId int64 `json:"ranUeNgapId"` + RrcEstablishmentCause RrcEstablishmentCause `json:"rrcEstablishmentCause"` + UeState UeState `json:"ueState"` + UeUsageSetting *UeUsageSetting `json:"ueUsageSetting,omitempty"` +} + +func (o *UeConnectionInfo5G) GetLastActivityTimeAsTime() (*time.Time, error) { + if o.LastActivityTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastActivityTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UeConnectionInfo5G) SetLastActivityTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastActivityTime = &formatted +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo4g.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo4g.go new file mode 100644 index 00000000000..d5f02fdd8c0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo4g.go @@ -0,0 +1,57 @@ +package extendedueinformation + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ExtendedUeInfoProperties = UeInfo4G{} + +type UeInfo4G struct { + Info UeInfo4GProperties `json:"info"` + + // Fields inherited from ExtendedUeInfoProperties + LastReadAt *string `json:"lastReadAt,omitempty"` +} + +func (o *UeInfo4G) GetLastReadAtAsTime() (*time.Time, error) { + if o.LastReadAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastReadAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *UeInfo4G) SetLastReadAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastReadAt = &formatted +} + +var _ json.Marshaler = UeInfo4G{} + +func (s UeInfo4G) MarshalJSON() ([]byte, error) { + type wrapper UeInfo4G + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UeInfo4G: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UeInfo4G: %+v", err) + } + decoded["ratType"] = "4G" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UeInfo4G: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo4gproperties.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo4gproperties.go new file mode 100644 index 00000000000..8533359c6bf --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo4gproperties.go @@ -0,0 +1,13 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeInfo4GProperties struct { + ConnectionInfo *UeConnectionInfo4G `json:"connectionInfo,omitempty"` + Guti Guti4G `json:"guti"` + Imei *string `json:"imei,omitempty"` + Imeisv *string `json:"imeisv,omitempty"` + Imsi string `json:"imsi"` + SessionInfo *[]UeSessionInfo4G `json:"sessionInfo,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo5g.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo5g.go new file mode 100644 index 00000000000..5efb7aff4c7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo5g.go @@ -0,0 +1,57 @@ +package extendedueinformation + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ExtendedUeInfoProperties = UeInfo5G{} + +type UeInfo5G struct { + Info UeInfo5GProperties `json:"info"` + + // Fields inherited from ExtendedUeInfoProperties + LastReadAt *string `json:"lastReadAt,omitempty"` +} + +func (o *UeInfo5G) GetLastReadAtAsTime() (*time.Time, error) { + if o.LastReadAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastReadAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *UeInfo5G) SetLastReadAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastReadAt = &formatted +} + +var _ json.Marshaler = UeInfo5G{} + +func (s UeInfo5G) MarshalJSON() ([]byte, error) { + type wrapper UeInfo5G + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UeInfo5G: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UeInfo5G: %+v", err) + } + decoded["ratType"] = "5G" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UeInfo5G: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo5gproperties.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo5gproperties.go new file mode 100644 index 00000000000..74a08320ae1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueinfo5gproperties.go @@ -0,0 +1,12 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeInfo5GProperties struct { + ConnectionInfo *UeConnectionInfo5G `json:"connectionInfo,omitempty"` + FivegGuti Guti5G `json:"fivegGuti"` + Pei *string `json:"pei,omitempty"` + SessionInfo *[]UeSessionInfo5G `json:"sessionInfo,omitempty"` + Supi string `json:"supi"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueipaddress.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueipaddress.go new file mode 100644 index 00000000000..859ccf29802 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueipaddress.go @@ -0,0 +1,8 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeIPAddress struct { + IPV4Addr *string `json:"ipV4Addr,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uelocationinfo.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uelocationinfo.go new file mode 100644 index 00000000000..294d962cbac --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uelocationinfo.go @@ -0,0 +1,10 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeLocationInfo struct { + LocationType string `json:"locationType"` + Plmn PlmnId `json:"plmn"` + Tac string `json:"tac"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueqosflow.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueqosflow.go new file mode 100644 index 00000000000..cb7b8bba026 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_ueqosflow.go @@ -0,0 +1,11 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeQOSFlow struct { + Fiveqi int64 `json:"fiveqi"` + Gbr *Ambr `json:"gbr,omitempty"` + Mbr *Ambr `json:"mbr,omitempty"` + Qfi int64 `json:"qfi"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uesessioninfo4g.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uesessioninfo4g.go new file mode 100644 index 00000000000..52d85429746 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uesessioninfo4g.go @@ -0,0 +1,11 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeSessionInfo4G struct { + Apn string `json:"apn"` + Ebi int64 `json:"ebi"` + PdnType PdnType `json:"pdnType"` + UeIPAddress UeIPAddress `json:"ueIpAddress"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uesessioninfo5g.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uesessioninfo5g.go new file mode 100644 index 00000000000..a39b264490e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/model_uesessioninfo5g.go @@ -0,0 +1,14 @@ +package extendedueinformation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeSessionInfo5G struct { + Ambr Ambr `json:"ambr"` + Dnn string `json:"dnn"` + PdnType PdnType `json:"pdnType"` + PduSessionId int64 `json:"pduSessionId"` + QosFlow []UeQOSFlow `json:"qosFlow"` + Snssai Snssai `json:"snssai"` + UeIPAddress UeIPAddress `json:"ueIpAddress"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/version.go b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/version.go new file mode 100644 index 00000000000..22fbee4a537 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/extendedueinformation/version.go @@ -0,0 +1,12 @@ +package extendedueinformation + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/extendedueinformation/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/README.md b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/README.md new file mode 100644 index 00000000000..21338094dce --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/mobilenetwork` Documentation + +The `mobilenetwork` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/mobilenetwork" +``` + + +### Client Initialization + +```go +client := mobilenetwork.NewMobileNetworkClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MobileNetworkClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := mobilenetwork.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +payload := mobilenetwork.MobileNetwork{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MobileNetworkClient.Delete` + +```go +ctx := context.TODO() +id := mobilenetwork.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MobileNetworkClient.Get` + +```go +ctx := context.TODO() +id := mobilenetwork.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MobileNetworkClient.UpdateTags` + +```go +ctx := context.TODO() +id := mobilenetwork.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +payload := mobilenetwork.IdentityAndTagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/client.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/client.go new file mode 100644 index 00000000000..f88a782b68d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/client.go @@ -0,0 +1,26 @@ +package mobilenetwork + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetworkClient struct { + Client *resourcemanager.Client +} + +func NewMobileNetworkClientWithBaseURI(sdkApi sdkEnv.Api) (*MobileNetworkClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "mobilenetwork", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MobileNetworkClient: %+v", err) + } + + return &MobileNetworkClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/constants.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/constants.go new file mode 100644 index 00000000000..49644d6258d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/constants.go @@ -0,0 +1,66 @@ +package mobilenetwork + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/id_mobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/id_mobilenetwork.go new file mode 100644 index 00000000000..20e7a777239 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/id_mobilenetwork.go @@ -0,0 +1,130 @@ +package mobilenetwork + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MobileNetworkId{}) +} + +var _ resourceids.ResourceId = &MobileNetworkId{} + +// MobileNetworkId is a struct representing the Resource ID for a Mobile Network +type MobileNetworkId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string +} + +// NewMobileNetworkID returns a new MobileNetworkId struct +func NewMobileNetworkID(subscriptionId string, resourceGroupName string, mobileNetworkName string) MobileNetworkId { + return MobileNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + } +} + +// ParseMobileNetworkID parses 'input' into a MobileNetworkId +func ParseMobileNetworkID(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMobileNetworkIDInsensitively parses 'input' case-insensitively into a MobileNetworkId +// note: this method should only be used for API response data and not user input +func ParseMobileNetworkIDInsensitively(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MobileNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + return nil +} + +// ValidateMobileNetworkID checks that 'input' can be parsed as a Mobile Network ID +func ValidateMobileNetworkID(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 := ParseMobileNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mobile Network ID +func (id MobileNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mobile Network ID +func (id MobileNetworkId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + } +} + +// String returns a human-readable description of this Mobile Network ID +func (id MobileNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + } + return fmt.Sprintf("Mobile Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/id_mobilenetwork_test.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/id_mobilenetwork_test.go new file mode 100644 index 00000000000..3571f3f5f31 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/id_mobilenetwork_test.go @@ -0,0 +1,282 @@ +package mobilenetwork + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MobileNetworkId{} + +func TestNewMobileNetworkID(t *testing.T) { + id := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } +} + +func TestFormatMobileNetworkID(t *testing.T) { + actual := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMobileNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestParseMobileNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestSegmentsForMobileNetworkId(t *testing.T) { + segments := MobileNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MobileNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_createorupdate.go new file mode 100644 index 00000000000..3ef2e7c22cd --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_createorupdate.go @@ -0,0 +1,75 @@ +package mobilenetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MobileNetwork +} + +// CreateOrUpdate ... +func (c MobileNetworkClient) CreateOrUpdate(ctx context.Context, id MobileNetworkId, input MobileNetwork) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c MobileNetworkClient) CreateOrUpdateThenPoll(ctx context.Context, id MobileNetworkId, input MobileNetwork) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_delete.go new file mode 100644 index 00000000000..d61a646e46c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_delete.go @@ -0,0 +1,71 @@ +package mobilenetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c MobileNetworkClient) Delete(ctx context.Context, id MobileNetworkId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c MobileNetworkClient) DeleteThenPoll(ctx context.Context, id MobileNetworkId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_get.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_get.go new file mode 100644 index 00000000000..b79e2d38c14 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_get.go @@ -0,0 +1,54 @@ +package mobilenetwork + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MobileNetwork +} + +// Get ... +func (c MobileNetworkClient) Get(ctx context.Context, id MobileNetworkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MobileNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_updatetags.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_updatetags.go new file mode 100644 index 00000000000..0d4e24e8d8e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/method_updatetags.go @@ -0,0 +1,58 @@ +package mobilenetwork + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MobileNetwork +} + +// UpdateTags ... +func (c MobileNetworkClient) UpdateTags(ctx context.Context, id MobileNetworkId, input IdentityAndTagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MobileNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_homenetworkpublickey.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_homenetworkpublickey.go new file mode 100644 index 00000000000..d3a72d756db --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_homenetworkpublickey.go @@ -0,0 +1,9 @@ +package mobilenetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HomeNetworkPublicKey struct { + Id int64 `json:"id"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_identityandtagsobject.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_identityandtagsobject.go new file mode 100644 index 00000000000..1b00aeff369 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_identityandtagsobject.go @@ -0,0 +1,13 @@ +package mobilenetwork + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityAndTagsObject struct { + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_mobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_mobilenetwork.go new file mode 100644 index 00000000000..190ea826460 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_mobilenetwork.go @@ -0,0 +1,20 @@ +package mobilenetwork + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetwork struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties MobileNetworkPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_mobilenetworkpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_mobilenetworkpropertiesformat.go new file mode 100644 index 00000000000..7e860dc5a04 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_mobilenetworkpropertiesformat.go @@ -0,0 +1,11 @@ +package mobilenetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetworkPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicLandMobileNetworkIdentifier PlmnId `json:"publicLandMobileNetworkIdentifier"` + PublicLandMobileNetworks *[]PublicLandMobileNetwork `json:"publicLandMobileNetworks,omitempty"` + ServiceKey *string `json:"serviceKey,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_plmnid.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_plmnid.go new file mode 100644 index 00000000000..bdd039f4149 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_plmnid.go @@ -0,0 +1,9 @@ +package mobilenetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlmnId struct { + Mcc string `json:"mcc"` + Mnc string `json:"mnc"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_publiclandmobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_publiclandmobilenetwork.go new file mode 100644 index 00000000000..5bde13f51b3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_publiclandmobilenetwork.go @@ -0,0 +1,10 @@ +package mobilenetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicLandMobileNetwork struct { + HomeNetworkPublicKeys *PublicLandMobileNetworkHomeNetworkPublicKeys `json:"homeNetworkPublicKeys,omitempty"` + Mcc string `json:"mcc"` + Mnc string `json:"mnc"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_publiclandmobilenetworkhomenetworkpublickeys.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_publiclandmobilenetworkhomenetworkpublickeys.go new file mode 100644 index 00000000000..f577a51c073 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/model_publiclandmobilenetworkhomenetworkpublickeys.go @@ -0,0 +1,9 @@ +package mobilenetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicLandMobileNetworkHomeNetworkPublicKeys struct { + ProfileA *[]HomeNetworkPublicKey `json:"profileA,omitempty"` + ProfileB *[]HomeNetworkPublicKey `json:"profileB,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/version.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/version.go new file mode 100644 index 00000000000..136ab1daa2d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetwork/version.go @@ -0,0 +1,12 @@ +package mobilenetwork + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/mobilenetwork/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/README.md b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/README.md new file mode 100644 index 00000000000..57383b8cb8c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/README.md @@ -0,0 +1,72 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/mobilenetworks` Documentation + +The `mobilenetworks` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/mobilenetworks" +``` + + +### Client Initialization + +```go +client := mobilenetworks.NewMobileNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MobileNetworksClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MobileNetworksClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MobileNetworksClient.ListSimGroups` + +```go +ctx := context.TODO() +id := mobilenetworks.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +// alternatively `client.ListSimGroups(ctx, id)` can be used to do batched pagination +items, err := client.ListSimGroupsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/client.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/client.go new file mode 100644 index 00000000000..699210d14c3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/client.go @@ -0,0 +1,26 @@ +package mobilenetworks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetworksClient struct { + Client *resourcemanager.Client +} + +func NewMobileNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*MobileNetworksClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "mobilenetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MobileNetworksClient: %+v", err) + } + + return &MobileNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/constants.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/constants.go new file mode 100644 index 00000000000..a663508f1b4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/constants.go @@ -0,0 +1,66 @@ +package mobilenetworks + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/id_mobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/id_mobilenetwork.go new file mode 100644 index 00000000000..0f1937975b8 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/id_mobilenetwork.go @@ -0,0 +1,130 @@ +package mobilenetworks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MobileNetworkId{}) +} + +var _ resourceids.ResourceId = &MobileNetworkId{} + +// MobileNetworkId is a struct representing the Resource ID for a Mobile Network +type MobileNetworkId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string +} + +// NewMobileNetworkID returns a new MobileNetworkId struct +func NewMobileNetworkID(subscriptionId string, resourceGroupName string, mobileNetworkName string) MobileNetworkId { + return MobileNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + } +} + +// ParseMobileNetworkID parses 'input' into a MobileNetworkId +func ParseMobileNetworkID(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMobileNetworkIDInsensitively parses 'input' case-insensitively into a MobileNetworkId +// note: this method should only be used for API response data and not user input +func ParseMobileNetworkIDInsensitively(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MobileNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + return nil +} + +// ValidateMobileNetworkID checks that 'input' can be parsed as a Mobile Network ID +func ValidateMobileNetworkID(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 := ParseMobileNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mobile Network ID +func (id MobileNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mobile Network ID +func (id MobileNetworkId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + } +} + +// String returns a human-readable description of this Mobile Network ID +func (id MobileNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + } + return fmt.Sprintf("Mobile Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/id_mobilenetwork_test.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/id_mobilenetwork_test.go new file mode 100644 index 00000000000..4fb3e78f8fb --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/id_mobilenetwork_test.go @@ -0,0 +1,282 @@ +package mobilenetworks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MobileNetworkId{} + +func TestNewMobileNetworkID(t *testing.T) { + id := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } +} + +func TestFormatMobileNetworkID(t *testing.T) { + actual := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMobileNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestParseMobileNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestSegmentsForMobileNetworkId(t *testing.T) { + segments := MobileNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MobileNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listbyresourcegroup.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listbyresourcegroup.go new file mode 100644 index 00000000000..e9b403e9ba0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package mobilenetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MobileNetwork +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []MobileNetwork +} + +// ListByResourceGroup ... +func (c MobileNetworksClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.MobileNetwork/mobileNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MobileNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c MobileNetworksClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, MobileNetworkOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MobileNetworksClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate MobileNetworkOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]MobileNetwork, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listbysubscription.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listbysubscription.go new file mode 100644 index 00000000000..05ecff2d9d3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listbysubscription.go @@ -0,0 +1,92 @@ +package mobilenetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MobileNetwork +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []MobileNetwork +} + +// ListBySubscription ... +func (c MobileNetworksClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.MobileNetwork/mobileNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MobileNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c MobileNetworksClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, MobileNetworkOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MobileNetworksClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate MobileNetworkOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]MobileNetwork, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listsimgroups.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listsimgroups.go new file mode 100644 index 00000000000..11ad17b8f29 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/method_listsimgroups.go @@ -0,0 +1,91 @@ +package mobilenetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSimGroupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SimGroup +} + +type ListSimGroupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SimGroup +} + +// ListSimGroups ... +func (c MobileNetworksClient) ListSimGroups(ctx context.Context, id MobileNetworkId) (result ListSimGroupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSimGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SimGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSimGroupsComplete retrieves all the results into a single object +func (c MobileNetworksClient) ListSimGroupsComplete(ctx context.Context, id MobileNetworkId) (ListSimGroupsCompleteResult, error) { + return c.ListSimGroupsCompleteMatchingPredicate(ctx, id, SimGroupOperationPredicate{}) +} + +// ListSimGroupsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MobileNetworksClient) ListSimGroupsCompleteMatchingPredicate(ctx context.Context, id MobileNetworkId, predicate SimGroupOperationPredicate) (result ListSimGroupsCompleteResult, err error) { + items := make([]SimGroup, 0) + + resp, err := c.ListSimGroups(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSimGroupsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_homenetworkpublickey.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_homenetworkpublickey.go new file mode 100644 index 00000000000..4622a897a37 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_homenetworkpublickey.go @@ -0,0 +1,9 @@ +package mobilenetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HomeNetworkPublicKey struct { + Id int64 `json:"id"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_keyvaultkey.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_keyvaultkey.go new file mode 100644 index 00000000000..07c51fddd92 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_keyvaultkey.go @@ -0,0 +1,8 @@ +package mobilenetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultKey struct { + KeyUrl *string `json:"keyUrl,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetwork.go new file mode 100644 index 00000000000..24d0930f2bb --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetwork.go @@ -0,0 +1,20 @@ +package mobilenetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetwork struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties MobileNetworkPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetworkpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetworkpropertiesformat.go new file mode 100644 index 00000000000..008ccec9d0d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetworkpropertiesformat.go @@ -0,0 +1,11 @@ +package mobilenetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetworkPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicLandMobileNetworkIdentifier PlmnId `json:"publicLandMobileNetworkIdentifier"` + PublicLandMobileNetworks *[]PublicLandMobileNetwork `json:"publicLandMobileNetworks,omitempty"` + ServiceKey *string `json:"serviceKey,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetworkresourceid.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetworkresourceid.go new file mode 100644 index 00000000000..ff28bcd0721 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_mobilenetworkresourceid.go @@ -0,0 +1,8 @@ +package mobilenetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetworkResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_plmnid.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_plmnid.go new file mode 100644 index 00000000000..a66f96c6f9a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_plmnid.go @@ -0,0 +1,9 @@ +package mobilenetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlmnId struct { + Mcc string `json:"mcc"` + Mnc string `json:"mnc"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_publiclandmobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_publiclandmobilenetwork.go new file mode 100644 index 00000000000..de0d9e0a4a9 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_publiclandmobilenetwork.go @@ -0,0 +1,10 @@ +package mobilenetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicLandMobileNetwork struct { + HomeNetworkPublicKeys *PublicLandMobileNetworkHomeNetworkPublicKeys `json:"homeNetworkPublicKeys,omitempty"` + Mcc string `json:"mcc"` + Mnc string `json:"mnc"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_publiclandmobilenetworkhomenetworkpublickeys.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_publiclandmobilenetworkhomenetworkpublickeys.go new file mode 100644 index 00000000000..cbce53f4d77 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_publiclandmobilenetworkhomenetworkpublickeys.go @@ -0,0 +1,9 @@ +package mobilenetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicLandMobileNetworkHomeNetworkPublicKeys struct { + ProfileA *[]HomeNetworkPublicKey `json:"profileA,omitempty"` + ProfileB *[]HomeNetworkPublicKey `json:"profileB,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_simgroup.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_simgroup.go new file mode 100644 index 00000000000..377198022d1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_simgroup.go @@ -0,0 +1,20 @@ +package mobilenetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimGroup struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties SimGroupPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_simgrouppropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_simgrouppropertiesformat.go new file mode 100644 index 00000000000..c5cdda6033c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/model_simgrouppropertiesformat.go @@ -0,0 +1,10 @@ +package mobilenetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimGroupPropertiesFormat struct { + EncryptionKey *KeyVaultKey `json:"encryptionKey,omitempty"` + MobileNetwork *MobileNetworkResourceId `json:"mobileNetwork,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/predicates.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/predicates.go new file mode 100644 index 00000000000..2f0cd98e05f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/predicates.go @@ -0,0 +1,60 @@ +package mobilenetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MobileNetworkOperationPredicate) Matches(input MobileNetwork) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SimGroupOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SimGroupOperationPredicate) Matches(input SimGroup) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/version.go b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/version.go new file mode 100644 index 00000000000..f3f0b75bf37 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/mobilenetworks/version.go @@ -0,0 +1,12 @@ +package mobilenetworks + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/mobilenetworks/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/README.md b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/README.md new file mode 100644 index 00000000000..5d0e6e1d1ec --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/README.md @@ -0,0 +1,94 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcaptures` Documentation + +The `packetcaptures` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcaptures" +``` + + +### Client Initialization + +```go +client := packetcaptures.NewPacketCapturesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCapturesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCaptureValue") + +payload := packetcaptures.PacketCapture{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PacketCapturesClient.Delete` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCaptureValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PacketCapturesClient.Get` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCaptureValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PacketCapturesClient.ListByPacketCoreControlPlane` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +// alternatively `client.ListByPacketCoreControlPlane(ctx, id)` can be used to do batched pagination +items, err := client.ListByPacketCoreControlPlaneComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PacketCapturesClient.Stop` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCaptureValue") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/client.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/client.go new file mode 100644 index 00000000000..03aa779a5b9 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/client.go @@ -0,0 +1,26 @@ +package packetcaptures + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCapturesClient struct { + Client *resourcemanager.Client +} + +func NewPacketCapturesClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCapturesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "packetcaptures", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCapturesClient: %+v", err) + } + + return &PacketCapturesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/constants.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/constants.go new file mode 100644 index 00000000000..b1d4595af85 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/constants.go @@ -0,0 +1,113 @@ +package packetcaptures + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureStatus string + +const ( + PacketCaptureStatusError PacketCaptureStatus = "Error" + PacketCaptureStatusNotStarted PacketCaptureStatus = "NotStarted" + PacketCaptureStatusRunning PacketCaptureStatus = "Running" + PacketCaptureStatusStopped PacketCaptureStatus = "Stopped" +) + +func PossibleValuesForPacketCaptureStatus() []string { + return []string{ + string(PacketCaptureStatusError), + string(PacketCaptureStatusNotStarted), + string(PacketCaptureStatusRunning), + string(PacketCaptureStatusStopped), + } +} + +func (s *PacketCaptureStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePacketCaptureStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePacketCaptureStatus(input string) (*PacketCaptureStatus, error) { + vals := map[string]PacketCaptureStatus{ + "error": PacketCaptureStatusError, + "notstarted": PacketCaptureStatusNotStarted, + "running": PacketCaptureStatusRunning, + "stopped": PacketCaptureStatusStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PacketCaptureStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcapture.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcapture.go new file mode 100644 index 00000000000..861325eb4b5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcapture.go @@ -0,0 +1,139 @@ +package packetcaptures + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCaptureId{}) +} + +var _ resourceids.ResourceId = &PacketCaptureId{} + +// PacketCaptureId is a struct representing the Resource ID for a Packet Capture +type PacketCaptureId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string + PacketCaptureName string +} + +// NewPacketCaptureID returns a new PacketCaptureId struct +func NewPacketCaptureID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string, packetCaptureName string) PacketCaptureId { + return PacketCaptureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + PacketCaptureName: packetCaptureName, + } +} + +// ParsePacketCaptureID parses 'input' into a PacketCaptureId +func ParsePacketCaptureID(input string) (*PacketCaptureId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCaptureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCaptureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCaptureIDInsensitively parses 'input' case-insensitively into a PacketCaptureId +// note: this method should only be used for API response data and not user input +func ParsePacketCaptureIDInsensitively(input string) (*PacketCaptureId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCaptureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCaptureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCaptureId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + if id.PacketCaptureName, ok = input.Parsed["packetCaptureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCaptureName", input) + } + + return nil +} + +// ValidatePacketCaptureID checks that 'input' can be parsed as a Packet Capture ID +func ValidatePacketCaptureID(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 := ParsePacketCaptureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Capture ID +func (id PacketCaptureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s/packetCaptures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName, id.PacketCaptureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Capture ID +func (id PacketCaptureId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + resourceids.StaticSegment("staticPacketCaptures", "packetCaptures", "packetCaptures"), + resourceids.UserSpecifiedSegment("packetCaptureName", "packetCaptureValue"), + } +} + +// String returns a human-readable description of this Packet Capture ID +func (id PacketCaptureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + fmt.Sprintf("Packet Capture Name: %q", id.PacketCaptureName), + } + return fmt.Sprintf("Packet Capture (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcapture_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcapture_test.go new file mode 100644 index 00000000000..35b808cba9b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcapture_test.go @@ -0,0 +1,327 @@ +package packetcaptures + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCaptureId{} + +func TestNewPacketCaptureID(t *testing.T) { + id := NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCaptureValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } + + if id.PacketCaptureName != "packetCaptureValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCaptureName'", id.PacketCaptureName, "packetCaptureValue") + } +} + +func TestFormatPacketCaptureID(t *testing.T) { + actual := NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCaptureValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCaptures/packetCaptureValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCaptureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCaptureId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCaptures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCaptures/packetCaptureValue", + Expected: &PacketCaptureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + PacketCaptureName: "packetCaptureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCaptures/packetCaptureValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCaptureID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.PacketCaptureName != v.Expected.PacketCaptureName { + t.Fatalf("Expected %q but got %q for PacketCaptureName", v.Expected.PacketCaptureName, actual.PacketCaptureName) + } + + } +} + +func TestParsePacketCaptureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCaptureId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCaptures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcApTuReS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCaptures/packetCaptureValue", + Expected: &PacketCaptureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + PacketCaptureName: "packetCaptureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCaptures/packetCaptureValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcApTuReS/pAcKeTcApTuReVaLuE", + Expected: &PacketCaptureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + PacketCaptureName: "pAcKeTcApTuReVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcApTuReS/pAcKeTcApTuReVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCaptureIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.PacketCaptureName != v.Expected.PacketCaptureName { + t.Fatalf("Expected %q but got %q for PacketCaptureName", v.Expected.PacketCaptureName, actual.PacketCaptureName) + } + + } +} + +func TestSegmentsForPacketCaptureId(t *testing.T) { + segments := PacketCaptureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCaptureId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcorecontrolplane.go new file mode 100644 index 00000000000..46ab74dad44 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcorecontrolplane.go @@ -0,0 +1,130 @@ +package packetcaptures + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +// PacketCoreControlPlaneId is a struct representing the Resource ID for a Packet Core Control Plane +type PacketCoreControlPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string +} + +// NewPacketCoreControlPlaneID returns a new PacketCoreControlPlaneId struct +func NewPacketCoreControlPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string) PacketCoreControlPlaneId { + return PacketCoreControlPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + } +} + +// ParsePacketCoreControlPlaneID parses 'input' into a PacketCoreControlPlaneId +func ParsePacketCoreControlPlaneID(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneIDInsensitively(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneID checks that 'input' can be parsed as a Packet Core Control Plane ID +func ValidatePacketCoreControlPlaneID(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 := ParsePacketCoreControlPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + } + return fmt.Sprintf("Packet Core Control Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcorecontrolplane_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcorecontrolplane_test.go new file mode 100644 index 00000000000..1e879f67cb4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/id_packetcorecontrolplane_test.go @@ -0,0 +1,282 @@ +package packetcaptures + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +func TestNewPacketCoreControlPlaneID(t *testing.T) { + id := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } +} + +func TestFormatPacketCoreControlPlaneID(t *testing.T) { + actual := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestParsePacketCoreControlPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneId(t *testing.T) { + segments := PacketCoreControlPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_createorupdate.go new file mode 100644 index 00000000000..c05df07d94c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_createorupdate.go @@ -0,0 +1,75 @@ +package packetcaptures + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PacketCapture +} + +// CreateOrUpdate ... +func (c PacketCapturesClient) CreateOrUpdate(ctx context.Context, id PacketCaptureId, input PacketCapture) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PacketCapturesClient) CreateOrUpdateThenPoll(ctx context.Context, id PacketCaptureId, input PacketCapture) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_delete.go new file mode 100644 index 00000000000..4f2efd034cc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_delete.go @@ -0,0 +1,71 @@ +package packetcaptures + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PacketCapturesClient) Delete(ctx context.Context, id PacketCaptureId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PacketCapturesClient) DeleteThenPoll(ctx context.Context, id PacketCaptureId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_get.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_get.go new file mode 100644 index 00000000000..eff0888c843 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_get.go @@ -0,0 +1,54 @@ +package packetcaptures + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PacketCapture +} + +// Get ... +func (c PacketCapturesClient) Get(ctx context.Context, id PacketCaptureId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PacketCapture + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_listbypacketcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_listbypacketcorecontrolplane.go new file mode 100644 index 00000000000..de9058102e8 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_listbypacketcorecontrolplane.go @@ -0,0 +1,91 @@ +package packetcaptures + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByPacketCoreControlPlaneOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PacketCapture +} + +type ListByPacketCoreControlPlaneCompleteResult struct { + LatestHttpResponse *http.Response + Items []PacketCapture +} + +// ListByPacketCoreControlPlane ... +func (c PacketCapturesClient) ListByPacketCoreControlPlane(ctx context.Context, id PacketCoreControlPlaneId) (result ListByPacketCoreControlPlaneOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/packetCaptures", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PacketCapture `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByPacketCoreControlPlaneComplete retrieves all the results into a single object +func (c PacketCapturesClient) ListByPacketCoreControlPlaneComplete(ctx context.Context, id PacketCoreControlPlaneId) (ListByPacketCoreControlPlaneCompleteResult, error) { + return c.ListByPacketCoreControlPlaneCompleteMatchingPredicate(ctx, id, PacketCaptureOperationPredicate{}) +} + +// ListByPacketCoreControlPlaneCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PacketCapturesClient) ListByPacketCoreControlPlaneCompleteMatchingPredicate(ctx context.Context, id PacketCoreControlPlaneId, predicate PacketCaptureOperationPredicate) (result ListByPacketCoreControlPlaneCompleteResult, err error) { + items := make([]PacketCapture, 0) + + resp, err := c.ListByPacketCoreControlPlane(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByPacketCoreControlPlaneCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_stop.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_stop.go new file mode 100644 index 00000000000..153033e1627 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/method_stop.go @@ -0,0 +1,71 @@ +package packetcaptures + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AsyncOperationStatus +} + +// Stop ... +func (c PacketCapturesClient) Stop(ctx context.Context, id PacketCaptureId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopThenPoll performs Stop then polls until it's completed +func (c PacketCapturesClient) StopThenPoll(ctx context.Context, id PacketCaptureId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_asyncoperationstatus.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_asyncoperationstatus.go new file mode 100644 index 00000000000..739a5db1fc6 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_asyncoperationstatus.go @@ -0,0 +1,46 @@ +package packetcaptures + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AsyncOperationStatus struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + Properties *interface{} `json:"properties,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *AsyncOperationStatus) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AsyncOperationStatus) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_erroradditionalinfo.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_erroradditionalinfo.go new file mode 100644 index 00000000000..3f15c7a40dc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_errordetail.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_errordetail.go new file mode 100644 index 00000000000..82f7591e70c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_errordetail.go @@ -0,0 +1,12 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_packetcapture.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_packetcapture.go new file mode 100644 index 00000000000..b71ffb17ca9 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_packetcapture.go @@ -0,0 +1,16 @@ +package packetcaptures + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCapture struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties PacketCapturePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_packetcapturepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_packetcapturepropertiesformat.go new file mode 100644 index 00000000000..f61fb8e39af --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/model_packetcapturepropertiesformat.go @@ -0,0 +1,34 @@ +package packetcaptures + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCapturePropertiesFormat struct { + BytesToCapturePerPacket *int64 `json:"bytesToCapturePerPacket,omitempty"` + CaptureStartTime *string `json:"captureStartTime,omitempty"` + NetworkInterfaces *[]string `json:"networkInterfaces,omitempty"` + OutputFiles *[]string `json:"outputFiles,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reason *string `json:"reason,omitempty"` + Status *PacketCaptureStatus `json:"status,omitempty"` + TimeLimitInSeconds *int64 `json:"timeLimitInSeconds,omitempty"` + TotalBytesPerSession *int64 `json:"totalBytesPerSession,omitempty"` +} + +func (o *PacketCapturePropertiesFormat) GetCaptureStartTimeAsTime() (*time.Time, error) { + if o.CaptureStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CaptureStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PacketCapturePropertiesFormat) SetCaptureStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CaptureStartTime = &formatted +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/predicates.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/predicates.go new file mode 100644 index 00000000000..c12967b6cc3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/predicates.go @@ -0,0 +1,27 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PacketCaptureOperationPredicate) Matches(input PacketCapture) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcaptures/version.go b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/version.go new file mode 100644 index 00000000000..4a0c87a1f18 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcaptures/version.go @@ -0,0 +1,12 @@ +package packetcaptures + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/packetcaptures/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/README.md b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/README.md new file mode 100644 index 00000000000..2aaf257c643 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane` Documentation + +The `packetcorecontrolplane` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane" +``` + + +### Client Initialization + +```go +client := packetcorecontrolplane.NewPacketCoreControlPlaneClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCoreControlPlaneClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := packetcorecontrolplane.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +payload := packetcorecontrolplane.PacketCoreControlPlane{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PacketCoreControlPlaneClient.Delete` + +```go +ctx := context.TODO() +id := packetcorecontrolplane.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PacketCoreControlPlaneClient.Get` + +```go +ctx := context.TODO() +id := packetcorecontrolplane.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PacketCoreControlPlaneClient.UpdateTags` + +```go +ctx := context.TODO() +id := packetcorecontrolplane.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +payload := packetcorecontrolplane.IdentityAndTagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/client.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/client.go new file mode 100644 index 00000000000..351920cd18e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/client.go @@ -0,0 +1,26 @@ +package packetcorecontrolplane + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneClient struct { + Client *resourcemanager.Client +} + +func NewPacketCoreControlPlaneClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCoreControlPlaneClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "packetcorecontrolplane", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCoreControlPlaneClient: %+v", err) + } + + return &PacketCoreControlPlaneClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/constants.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/constants.go new file mode 100644 index 00000000000..6d40ad518dc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/constants.go @@ -0,0 +1,580 @@ +package packetcorecontrolplane + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationType string + +const ( + AuthenticationTypeAAD AuthenticationType = "AAD" + AuthenticationTypePassword AuthenticationType = "Password" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeAAD), + string(AuthenticationTypePassword), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "aad": AuthenticationTypeAAD, + "password": AuthenticationTypePassword, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type BillingSku string + +const ( + BillingSkuGFive BillingSku = "G5" + BillingSkuGOne BillingSku = "G1" + BillingSkuGOneZero BillingSku = "G10" + BillingSkuGTwo BillingSku = "G2" + BillingSkuGZero BillingSku = "G0" +) + +func PossibleValuesForBillingSku() []string { + return []string{ + string(BillingSkuGFive), + string(BillingSkuGOne), + string(BillingSkuGOneZero), + string(BillingSkuGTwo), + string(BillingSkuGZero), + } +} + +func (s *BillingSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBillingSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBillingSku(input string) (*BillingSku, error) { + vals := map[string]BillingSku{ + "g5": BillingSkuGFive, + "g1": BillingSkuGOne, + "g10": BillingSkuGOneZero, + "g2": BillingSkuGTwo, + "g0": BillingSkuGZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BillingSku(input) + return &out, nil +} + +type CertificateProvisioningState string + +const ( + CertificateProvisioningStateFailed CertificateProvisioningState = "Failed" + CertificateProvisioningStateNotProvisioned CertificateProvisioningState = "NotProvisioned" + CertificateProvisioningStateProvisioned CertificateProvisioningState = "Provisioned" +) + +func PossibleValuesForCertificateProvisioningState() []string { + return []string{ + string(CertificateProvisioningStateFailed), + string(CertificateProvisioningStateNotProvisioned), + string(CertificateProvisioningStateProvisioned), + } +} + +func (s *CertificateProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProvisioningState(input string) (*CertificateProvisioningState, error) { + vals := map[string]CertificateProvisioningState{ + "failed": CertificateProvisioningStateFailed, + "notprovisioned": CertificateProvisioningStateNotProvisioned, + "provisioned": CertificateProvisioningStateProvisioned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProvisioningState(input) + return &out, nil +} + +type CoreNetworkType string + +const ( + CoreNetworkTypeEPC CoreNetworkType = "EPC" + CoreNetworkTypeEPCPositiveFiveGC CoreNetworkType = "EPC + 5GC" + CoreNetworkTypeFiveGC CoreNetworkType = "5GC" +) + +func PossibleValuesForCoreNetworkType() []string { + return []string{ + string(CoreNetworkTypeEPC), + string(CoreNetworkTypeEPCPositiveFiveGC), + string(CoreNetworkTypeFiveGC), + } +} + +func (s *CoreNetworkType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCoreNetworkType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCoreNetworkType(input string) (*CoreNetworkType, error) { + vals := map[string]CoreNetworkType{ + "epc": CoreNetworkTypeEPC, + "epc + 5gc": CoreNetworkTypeEPCPositiveFiveGC, + "5gc": CoreNetworkTypeFiveGC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CoreNetworkType(input) + return &out, nil +} + +type DesiredInstallationState string + +const ( + DesiredInstallationStateInstalled DesiredInstallationState = "Installed" + DesiredInstallationStateUninstalled DesiredInstallationState = "Uninstalled" +) + +func PossibleValuesForDesiredInstallationState() []string { + return []string{ + string(DesiredInstallationStateInstalled), + string(DesiredInstallationStateUninstalled), + } +} + +func (s *DesiredInstallationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDesiredInstallationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDesiredInstallationState(input string) (*DesiredInstallationState, error) { + vals := map[string]DesiredInstallationState{ + "installed": DesiredInstallationStateInstalled, + "uninstalled": DesiredInstallationStateUninstalled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DesiredInstallationState(input) + return &out, nil +} + +type HomeNetworkPrivateKeysProvisioningState string + +const ( + HomeNetworkPrivateKeysProvisioningStateFailed HomeNetworkPrivateKeysProvisioningState = "Failed" + HomeNetworkPrivateKeysProvisioningStateNotProvisioned HomeNetworkPrivateKeysProvisioningState = "NotProvisioned" + HomeNetworkPrivateKeysProvisioningStateProvisioned HomeNetworkPrivateKeysProvisioningState = "Provisioned" +) + +func PossibleValuesForHomeNetworkPrivateKeysProvisioningState() []string { + return []string{ + string(HomeNetworkPrivateKeysProvisioningStateFailed), + string(HomeNetworkPrivateKeysProvisioningStateNotProvisioned), + string(HomeNetworkPrivateKeysProvisioningStateProvisioned), + } +} + +func (s *HomeNetworkPrivateKeysProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHomeNetworkPrivateKeysProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHomeNetworkPrivateKeysProvisioningState(input string) (*HomeNetworkPrivateKeysProvisioningState, error) { + vals := map[string]HomeNetworkPrivateKeysProvisioningState{ + "failed": HomeNetworkPrivateKeysProvisioningStateFailed, + "notprovisioned": HomeNetworkPrivateKeysProvisioningStateNotProvisioned, + "provisioned": HomeNetworkPrivateKeysProvisioningStateProvisioned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HomeNetworkPrivateKeysProvisioningState(input) + return &out, nil +} + +type InstallationReason string + +const ( + InstallationReasonControlPlaneAccessInterfaceHasChanged InstallationReason = "ControlPlaneAccessInterfaceHasChanged" + InstallationReasonControlPlaneAccessVirtualIPvFourAddressesHasChanged InstallationReason = "ControlPlaneAccessVirtualIpv4AddressesHasChanged" + InstallationReasonNoAttachedDataNetworks InstallationReason = "NoAttachedDataNetworks" + InstallationReasonNoPacketCoreDataPlane InstallationReason = "NoPacketCoreDataPlane" + InstallationReasonNoSlices InstallationReason = "NoSlices" + InstallationReasonPublicLandMobileNetworkIdentifierHasChanged InstallationReason = "PublicLandMobileNetworkIdentifierHasChanged" + InstallationReasonUserPlaneAccessInterfaceHasChanged InstallationReason = "UserPlaneAccessInterfaceHasChanged" + InstallationReasonUserPlaneAccessVirtualIPvFourAddressesHasChanged InstallationReason = "UserPlaneAccessVirtualIpv4AddressesHasChanged" + InstallationReasonUserPlaneDataInterfaceHasChanged InstallationReason = "UserPlaneDataInterfaceHasChanged" +) + +func PossibleValuesForInstallationReason() []string { + return []string{ + string(InstallationReasonControlPlaneAccessInterfaceHasChanged), + string(InstallationReasonControlPlaneAccessVirtualIPvFourAddressesHasChanged), + string(InstallationReasonNoAttachedDataNetworks), + string(InstallationReasonNoPacketCoreDataPlane), + string(InstallationReasonNoSlices), + string(InstallationReasonPublicLandMobileNetworkIdentifierHasChanged), + string(InstallationReasonUserPlaneAccessInterfaceHasChanged), + string(InstallationReasonUserPlaneAccessVirtualIPvFourAddressesHasChanged), + string(InstallationReasonUserPlaneDataInterfaceHasChanged), + } +} + +func (s *InstallationReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInstallationReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInstallationReason(input string) (*InstallationReason, error) { + vals := map[string]InstallationReason{ + "controlplaneaccessinterfacehaschanged": InstallationReasonControlPlaneAccessInterfaceHasChanged, + "controlplaneaccessvirtualipv4addresseshaschanged": InstallationReasonControlPlaneAccessVirtualIPvFourAddressesHasChanged, + "noattacheddatanetworks": InstallationReasonNoAttachedDataNetworks, + "nopacketcoredataplane": InstallationReasonNoPacketCoreDataPlane, + "noslices": InstallationReasonNoSlices, + "publiclandmobilenetworkidentifierhaschanged": InstallationReasonPublicLandMobileNetworkIdentifierHasChanged, + "userplaneaccessinterfacehaschanged": InstallationReasonUserPlaneAccessInterfaceHasChanged, + "userplaneaccessvirtualipv4addresseshaschanged": InstallationReasonUserPlaneAccessVirtualIPvFourAddressesHasChanged, + "userplanedatainterfacehaschanged": InstallationReasonUserPlaneDataInterfaceHasChanged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InstallationReason(input) + return &out, nil +} + +type InstallationState string + +const ( + InstallationStateFailed InstallationState = "Failed" + InstallationStateInstalled InstallationState = "Installed" + InstallationStateInstalling InstallationState = "Installing" + InstallationStateReinstalling InstallationState = "Reinstalling" + InstallationStateRollingBack InstallationState = "RollingBack" + InstallationStateUninstalled InstallationState = "Uninstalled" + InstallationStateUninstalling InstallationState = "Uninstalling" + InstallationStateUpdating InstallationState = "Updating" + InstallationStateUpgrading InstallationState = "Upgrading" +) + +func PossibleValuesForInstallationState() []string { + return []string{ + string(InstallationStateFailed), + string(InstallationStateInstalled), + string(InstallationStateInstalling), + string(InstallationStateReinstalling), + string(InstallationStateRollingBack), + string(InstallationStateUninstalled), + string(InstallationStateUninstalling), + string(InstallationStateUpdating), + string(InstallationStateUpgrading), + } +} + +func (s *InstallationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInstallationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInstallationState(input string) (*InstallationState, error) { + vals := map[string]InstallationState{ + "failed": InstallationStateFailed, + "installed": InstallationStateInstalled, + "installing": InstallationStateInstalling, + "reinstalling": InstallationStateReinstalling, + "rollingback": InstallationStateRollingBack, + "uninstalled": InstallationStateUninstalled, + "uninstalling": InstallationStateUninstalling, + "updating": InstallationStateUpdating, + "upgrading": InstallationStateUpgrading, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InstallationState(input) + return &out, nil +} + +type NasEncryptionType string + +const ( + NasEncryptionTypeNEAOneEEAOne NasEncryptionType = "NEA1/EEA1" + NasEncryptionTypeNEATwoEEATwo NasEncryptionType = "NEA2/EEA2" + NasEncryptionTypeNEAZeroEEAZero NasEncryptionType = "NEA0/EEA0" +) + +func PossibleValuesForNasEncryptionType() []string { + return []string{ + string(NasEncryptionTypeNEAOneEEAOne), + string(NasEncryptionTypeNEATwoEEATwo), + string(NasEncryptionTypeNEAZeroEEAZero), + } +} + +func (s *NasEncryptionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNasEncryptionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNasEncryptionType(input string) (*NasEncryptionType, error) { + vals := map[string]NasEncryptionType{ + "nea1/eea1": NasEncryptionTypeNEAOneEEAOne, + "nea2/eea2": NasEncryptionTypeNEATwoEEATwo, + "nea0/eea0": NasEncryptionTypeNEAZeroEEAZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NasEncryptionType(input) + return &out, nil +} + +type PlatformType string + +const ( + PlatformTypeAKSNegativeHCI PlatformType = "AKS-HCI" + PlatformTypeThreePNegativeAZURENegativeSTACKNegativeHCI PlatformType = "3P-AZURE-STACK-HCI" +) + +func PossibleValuesForPlatformType() []string { + return []string{ + string(PlatformTypeAKSNegativeHCI), + string(PlatformTypeThreePNegativeAZURENegativeSTACKNegativeHCI), + } +} + +func (s *PlatformType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePlatformType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePlatformType(input string) (*PlatformType, error) { + vals := map[string]PlatformType{ + "aks-hci": PlatformTypeAKSNegativeHCI, + "3p-azure-stack-hci": PlatformTypeThreePNegativeAZURENegativeSTACKNegativeHCI, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PlatformType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + 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 ReinstallRequired string + +const ( + ReinstallRequiredNotRequired ReinstallRequired = "NotRequired" + ReinstallRequiredRequired ReinstallRequired = "Required" +) + +func PossibleValuesForReinstallRequired() []string { + return []string{ + string(ReinstallRequiredNotRequired), + string(ReinstallRequiredRequired), + } +} + +func (s *ReinstallRequired) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReinstallRequired(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReinstallRequired(input string) (*ReinstallRequired, error) { + vals := map[string]ReinstallRequired{ + "notrequired": ReinstallRequiredNotRequired, + "required": ReinstallRequiredRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReinstallRequired(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/id_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/id_packetcorecontrolplane.go new file mode 100644 index 00000000000..17beafd27d8 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/id_packetcorecontrolplane.go @@ -0,0 +1,130 @@ +package packetcorecontrolplane + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +// PacketCoreControlPlaneId is a struct representing the Resource ID for a Packet Core Control Plane +type PacketCoreControlPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string +} + +// NewPacketCoreControlPlaneID returns a new PacketCoreControlPlaneId struct +func NewPacketCoreControlPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string) PacketCoreControlPlaneId { + return PacketCoreControlPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + } +} + +// ParsePacketCoreControlPlaneID parses 'input' into a PacketCoreControlPlaneId +func ParsePacketCoreControlPlaneID(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneIDInsensitively(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneID checks that 'input' can be parsed as a Packet Core Control Plane ID +func ValidatePacketCoreControlPlaneID(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 := ParsePacketCoreControlPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + } + return fmt.Sprintf("Packet Core Control Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/id_packetcorecontrolplane_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/id_packetcorecontrolplane_test.go new file mode 100644 index 00000000000..0eb359c9e6c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/id_packetcorecontrolplane_test.go @@ -0,0 +1,282 @@ +package packetcorecontrolplane + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +func TestNewPacketCoreControlPlaneID(t *testing.T) { + id := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } +} + +func TestFormatPacketCoreControlPlaneID(t *testing.T) { + actual := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestParsePacketCoreControlPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneId(t *testing.T) { + segments := PacketCoreControlPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_createorupdate.go new file mode 100644 index 00000000000..443cef32e45 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_createorupdate.go @@ -0,0 +1,75 @@ +package packetcorecontrolplane + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PacketCoreControlPlane +} + +// CreateOrUpdate ... +func (c PacketCoreControlPlaneClient) CreateOrUpdate(ctx context.Context, id PacketCoreControlPlaneId, input PacketCoreControlPlane) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PacketCoreControlPlaneClient) CreateOrUpdateThenPoll(ctx context.Context, id PacketCoreControlPlaneId, input PacketCoreControlPlane) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_delete.go new file mode 100644 index 00000000000..d477d8e26e2 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_delete.go @@ -0,0 +1,71 @@ +package packetcorecontrolplane + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PacketCoreControlPlaneClient) Delete(ctx context.Context, id PacketCoreControlPlaneId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PacketCoreControlPlaneClient) DeleteThenPoll(ctx context.Context, id PacketCoreControlPlaneId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_get.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_get.go new file mode 100644 index 00000000000..924161ba22f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_get.go @@ -0,0 +1,54 @@ +package packetcorecontrolplane + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PacketCoreControlPlane +} + +// Get ... +func (c PacketCoreControlPlaneClient) Get(ctx context.Context, id PacketCoreControlPlaneId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PacketCoreControlPlane + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_updatetags.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_updatetags.go new file mode 100644 index 00000000000..5da4d26d562 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/method_updatetags.go @@ -0,0 +1,58 @@ +package packetcorecontrolplane + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PacketCoreControlPlane +} + +// UpdateTags ... +func (c PacketCoreControlPlaneClient) UpdateTags(ctx context.Context, id PacketCoreControlPlaneId, input IdentityAndTagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PacketCoreControlPlane + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_asyncoperationid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_asyncoperationid.go new file mode 100644 index 00000000000..24e4dab2283 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_asyncoperationid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AsyncOperationId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_azurestackedgedeviceresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_azurestackedgedeviceresourceid.go new file mode 100644 index 00000000000..5f99e9edf8f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_azurestackedgedeviceresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStackEdgeDeviceResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_azurestackhciclusterresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_azurestackhciclusterresourceid.go new file mode 100644 index 00000000000..85bd2b6fac9 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_azurestackhciclusterresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStackHCIClusterResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_certificateprovisioning.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_certificateprovisioning.go new file mode 100644 index 00000000000..5c8169c9838 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_certificateprovisioning.go @@ -0,0 +1,9 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProvisioning struct { + Reason *string `json:"reason,omitempty"` + State *CertificateProvisioningState `json:"state,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_connectedclusterresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_connectedclusterresourceid.go new file mode 100644 index 00000000000..6bd59f8f18f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_connectedclusterresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedClusterResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_customlocationresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_customlocationresourceid.go new file mode 100644 index 00000000000..7dc1be7cb7a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_customlocationresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomLocationResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_diagnosticsuploadconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_diagnosticsuploadconfiguration.go new file mode 100644 index 00000000000..fef0d2bca43 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_diagnosticsuploadconfiguration.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsUploadConfiguration struct { + StorageAccountContainerUrl string `json:"storageAccountContainerUrl"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_eventhubconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_eventhubconfiguration.go new file mode 100644 index 00000000000..1de78ea1040 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_eventhubconfiguration.go @@ -0,0 +1,9 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventHubConfiguration struct { + Id string `json:"id"` + ReportingInterval *int64 `json:"reportingInterval,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_homenetworkprivatekeysprovisioning.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_homenetworkprivatekeysprovisioning.go new file mode 100644 index 00000000000..c5bca5665bd --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_homenetworkprivatekeysprovisioning.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HomeNetworkPrivateKeysProvisioning struct { + State HomeNetworkPrivateKeysProvisioningState `json:"state"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_httpsservercertificate.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_httpsservercertificate.go new file mode 100644 index 00000000000..be8a65a3fd5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_httpsservercertificate.go @@ -0,0 +1,9 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSServerCertificate struct { + CertificateUrl string `json:"certificateUrl"` + Provisioning *CertificateProvisioning `json:"provisioning,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_identityandtagsobject.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_identityandtagsobject.go new file mode 100644 index 00000000000..57a222eed52 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_identityandtagsobject.go @@ -0,0 +1,13 @@ +package packetcorecontrolplane + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityAndTagsObject struct { + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_installation.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_installation.go new file mode 100644 index 00000000000..01700d8b5e0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_installation.go @@ -0,0 +1,12 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Installation struct { + DesiredState *DesiredInstallationState `json:"desiredState,omitempty"` + Operation *AsyncOperationId `json:"operation,omitempty"` + Reasons *[]InstallationReason `json:"reasons,omitempty"` + ReinstallRequired *ReinstallRequired `json:"reinstallRequired,omitempty"` + State *InstallationState `json:"state,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_interfaceproperties.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_interfaceproperties.go new file mode 100644 index 00000000000..46ef7e08536 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_interfaceproperties.go @@ -0,0 +1,14 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InterfaceProperties struct { + BfdIPv4Endpoints *[]string `json:"bfdIpv4Endpoints,omitempty"` + IPv4Address *string `json:"ipv4Address,omitempty"` + IPv4AddressList *[]string `json:"ipv4AddressList,omitempty"` + IPv4Gateway *string `json:"ipv4Gateway,omitempty"` + IPv4Subnet *string `json:"ipv4Subnet,omitempty"` + Name *string `json:"name,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_localdiagnosticsaccessconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_localdiagnosticsaccessconfiguration.go new file mode 100644 index 00000000000..119ed642353 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_localdiagnosticsaccessconfiguration.go @@ -0,0 +1,9 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalDiagnosticsAccessConfiguration struct { + AuthenticationType AuthenticationType `json:"authenticationType"` + HTTPSServerCertificate *HTTPSServerCertificate `json:"httpsServerCertificate,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_nasrerouteconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_nasrerouteconfiguration.go new file mode 100644 index 00000000000..21e67858800 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_nasrerouteconfiguration.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NASRerouteConfiguration struct { + MacroMmeGroupId int64 `json:"macroMmeGroupId"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_packetcorecontrolplane.go new file mode 100644 index 00000000000..eb271ac8ecc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_packetcorecontrolplane.go @@ -0,0 +1,20 @@ +package packetcorecontrolplane + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlane struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties PacketCoreControlPlanePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_packetcorecontrolplanepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_packetcorecontrolplanepropertiesformat.go new file mode 100644 index 00000000000..0c5e1e0a789 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_packetcorecontrolplanepropertiesformat.go @@ -0,0 +1,26 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlanePropertiesFormat struct { + ControlPlaneAccessInterface InterfaceProperties `json:"controlPlaneAccessInterface"` + ControlPlaneAccessVirtualIPv4Addresses *[]string `json:"controlPlaneAccessVirtualIpv4Addresses,omitempty"` + CoreNetworkTechnology *CoreNetworkType `json:"coreNetworkTechnology,omitempty"` + DiagnosticsUpload *DiagnosticsUploadConfiguration `json:"diagnosticsUpload,omitempty"` + EventHub *EventHubConfiguration `json:"eventHub,omitempty"` + HomeNetworkPrivateKeysProvisioning *HomeNetworkPrivateKeysProvisioning `json:"homeNetworkPrivateKeysProvisioning,omitempty"` + Installation *Installation `json:"installation,omitempty"` + InstalledVersion *string `json:"installedVersion,omitempty"` + InteropSettings *interface{} `json:"interopSettings,omitempty"` + LocalDiagnosticsAccess LocalDiagnosticsAccessConfiguration `json:"localDiagnosticsAccess"` + Platform PlatformConfiguration `json:"platform"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RollbackVersion *string `json:"rollbackVersion,omitempty"` + Signaling *SignalingConfiguration `json:"signaling,omitempty"` + Sites []SiteResourceId `json:"sites"` + Sku BillingSku `json:"sku"` + UeMtu *int64 `json:"ueMtu,omitempty"` + UserConsent *UserConsentConfiguration `json:"userConsent,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_platformconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_platformconfiguration.go new file mode 100644 index 00000000000..70b61a111e2 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_platformconfiguration.go @@ -0,0 +1,13 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlatformConfiguration struct { + AzureStackEdgeDevice *AzureStackEdgeDeviceResourceId `json:"azureStackEdgeDevice,omitempty"` + AzureStackEdgeDevices *[]AzureStackEdgeDeviceResourceId `json:"azureStackEdgeDevices,omitempty"` + AzureStackHciCluster *AzureStackHCIClusterResourceId `json:"azureStackHciCluster,omitempty"` + ConnectedCluster *ConnectedClusterResourceId `json:"connectedCluster,omitempty"` + CustomLocation *CustomLocationResourceId `json:"customLocation,omitempty"` + Type PlatformType `json:"type"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_signalingconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_signalingconfiguration.go new file mode 100644 index 00000000000..7edc2ea978d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_signalingconfiguration.go @@ -0,0 +1,9 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalingConfiguration struct { + NasEncryption *[]NasEncryptionType `json:"nasEncryption,omitempty"` + NasReroute *NASRerouteConfiguration `json:"nasReroute,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_siteresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_siteresourceid.go new file mode 100644 index 00000000000..36e99f34ea8 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_siteresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_userconsentconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_userconsentconfiguration.go new file mode 100644 index 00000000000..6b9ba884c4c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/model_userconsentconfiguration.go @@ -0,0 +1,8 @@ +package packetcorecontrolplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserConsentConfiguration struct { + AllowSupportTelemetryAccess *bool `json:"allowSupportTelemetryAccess,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/version.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/version.go new file mode 100644 index 00000000000..28eed6b994d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplane/version.go @@ -0,0 +1,12 @@ +package packetcorecontrolplane + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/packetcorecontrolplane/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/README.md b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/README.md new file mode 100644 index 00000000000..cc2373f36ad --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage` Documentation + +The `packetcorecontrolplanecollectdiagnosticspackage` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage" +``` + + +### Client Initialization + +```go +client := packetcorecontrolplanecollectdiagnosticspackage.NewPacketCoreControlPlaneCollectDiagnosticsPackageClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCoreControlPlaneCollectDiagnosticsPackageClient.PacketCoreControlPlanesCollectDiagnosticsPackage` + +```go +ctx := context.TODO() +id := packetcorecontrolplanecollectdiagnosticspackage.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +payload := packetcorecontrolplanecollectdiagnosticspackage.PacketCoreControlPlaneCollectDiagnosticsPackage{ + // ... +} + + +if err := client.PacketCoreControlPlanesCollectDiagnosticsPackageThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/client.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/client.go new file mode 100644 index 00000000000..d4f71ea2b81 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/client.go @@ -0,0 +1,26 @@ +package packetcorecontrolplanecollectdiagnosticspackage + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneCollectDiagnosticsPackageClient struct { + Client *resourcemanager.Client +} + +func NewPacketCoreControlPlaneCollectDiagnosticsPackageClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCoreControlPlaneCollectDiagnosticsPackageClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "packetcorecontrolplanecollectdiagnosticspackage", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCoreControlPlaneCollectDiagnosticsPackageClient: %+v", err) + } + + return &PacketCoreControlPlaneCollectDiagnosticsPackageClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/id_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/id_packetcorecontrolplane.go new file mode 100644 index 00000000000..8d3d80dd4c7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/id_packetcorecontrolplane.go @@ -0,0 +1,130 @@ +package packetcorecontrolplanecollectdiagnosticspackage + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +// PacketCoreControlPlaneId is a struct representing the Resource ID for a Packet Core Control Plane +type PacketCoreControlPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string +} + +// NewPacketCoreControlPlaneID returns a new PacketCoreControlPlaneId struct +func NewPacketCoreControlPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string) PacketCoreControlPlaneId { + return PacketCoreControlPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + } +} + +// ParsePacketCoreControlPlaneID parses 'input' into a PacketCoreControlPlaneId +func ParsePacketCoreControlPlaneID(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneIDInsensitively(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneID checks that 'input' can be parsed as a Packet Core Control Plane ID +func ValidatePacketCoreControlPlaneID(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 := ParsePacketCoreControlPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + } + return fmt.Sprintf("Packet Core Control Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/id_packetcorecontrolplane_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/id_packetcorecontrolplane_test.go new file mode 100644 index 00000000000..f5733905f7f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/id_packetcorecontrolplane_test.go @@ -0,0 +1,282 @@ +package packetcorecontrolplanecollectdiagnosticspackage + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +func TestNewPacketCoreControlPlaneID(t *testing.T) { + id := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } +} + +func TestFormatPacketCoreControlPlaneID(t *testing.T) { + actual := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestParsePacketCoreControlPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneId(t *testing.T) { + segments := PacketCoreControlPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/method_packetcorecontrolplanescollectdiagnosticspackage.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/method_packetcorecontrolplanescollectdiagnosticspackage.go new file mode 100644 index 00000000000..841df3d8715 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/method_packetcorecontrolplanescollectdiagnosticspackage.go @@ -0,0 +1,75 @@ +package packetcorecontrolplanecollectdiagnosticspackage + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlanesCollectDiagnosticsPackageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AsyncOperationStatus +} + +// PacketCoreControlPlanesCollectDiagnosticsPackage ... +func (c PacketCoreControlPlaneCollectDiagnosticsPackageClient) PacketCoreControlPlanesCollectDiagnosticsPackage(ctx context.Context, id PacketCoreControlPlaneId, input PacketCoreControlPlaneCollectDiagnosticsPackage) (result PacketCoreControlPlanesCollectDiagnosticsPackageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/collectDiagnosticsPackage", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PacketCoreControlPlanesCollectDiagnosticsPackageThenPoll performs PacketCoreControlPlanesCollectDiagnosticsPackage then polls until it's completed +func (c PacketCoreControlPlaneCollectDiagnosticsPackageClient) PacketCoreControlPlanesCollectDiagnosticsPackageThenPoll(ctx context.Context, id PacketCoreControlPlaneId, input PacketCoreControlPlaneCollectDiagnosticsPackage) error { + result, err := c.PacketCoreControlPlanesCollectDiagnosticsPackage(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PacketCoreControlPlanesCollectDiagnosticsPackage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PacketCoreControlPlanesCollectDiagnosticsPackage: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_asyncoperationstatus.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_asyncoperationstatus.go new file mode 100644 index 00000000000..2da12dc8233 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_asyncoperationstatus.go @@ -0,0 +1,46 @@ +package packetcorecontrolplanecollectdiagnosticspackage + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AsyncOperationStatus struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + Properties *interface{} `json:"properties,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *AsyncOperationStatus) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AsyncOperationStatus) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_erroradditionalinfo.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_erroradditionalinfo.go new file mode 100644 index 00000000000..f11eed9038d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package packetcorecontrolplanecollectdiagnosticspackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_errordetail.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_errordetail.go new file mode 100644 index 00000000000..f9158816311 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_errordetail.go @@ -0,0 +1,12 @@ +package packetcorecontrolplanecollectdiagnosticspackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_packetcorecontrolplanecollectdiagnosticspackage.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_packetcorecontrolplanecollectdiagnosticspackage.go new file mode 100644 index 00000000000..7016c998d90 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/model_packetcorecontrolplanecollectdiagnosticspackage.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanecollectdiagnosticspackage + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneCollectDiagnosticsPackage struct { + StorageAccountBlobUrl string `json:"storageAccountBlobUrl"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/version.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/version.go new file mode 100644 index 00000000000..0b713ec34b7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanecollectdiagnosticspackage/version.go @@ -0,0 +1,12 @@ +package packetcorecontrolplanecollectdiagnosticspackage + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/packetcorecontrolplanecollectdiagnosticspackage/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/README.md b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/README.md new file mode 100644 index 00000000000..534bf471699 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/README.md @@ -0,0 +1,32 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall` Documentation + +The `packetcorecontrolplanereinstall` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall" +``` + + +### Client Initialization + +```go +client := packetcorecontrolplanereinstall.NewPacketCoreControlPlaneReinstallClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCoreControlPlaneReinstallClient.PacketCoreControlPlanesReinstall` + +```go +ctx := context.TODO() +id := packetcorecontrolplanereinstall.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +if err := client.PacketCoreControlPlanesReinstallThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/client.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/client.go new file mode 100644 index 00000000000..be193471bf0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/client.go @@ -0,0 +1,26 @@ +package packetcorecontrolplanereinstall + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneReinstallClient struct { + Client *resourcemanager.Client +} + +func NewPacketCoreControlPlaneReinstallClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCoreControlPlaneReinstallClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "packetcorecontrolplanereinstall", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCoreControlPlaneReinstallClient: %+v", err) + } + + return &PacketCoreControlPlaneReinstallClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/id_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/id_packetcorecontrolplane.go new file mode 100644 index 00000000000..f8c20476681 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/id_packetcorecontrolplane.go @@ -0,0 +1,130 @@ +package packetcorecontrolplanereinstall + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +// PacketCoreControlPlaneId is a struct representing the Resource ID for a Packet Core Control Plane +type PacketCoreControlPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string +} + +// NewPacketCoreControlPlaneID returns a new PacketCoreControlPlaneId struct +func NewPacketCoreControlPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string) PacketCoreControlPlaneId { + return PacketCoreControlPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + } +} + +// ParsePacketCoreControlPlaneID parses 'input' into a PacketCoreControlPlaneId +func ParsePacketCoreControlPlaneID(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneIDInsensitively(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneID checks that 'input' can be parsed as a Packet Core Control Plane ID +func ValidatePacketCoreControlPlaneID(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 := ParsePacketCoreControlPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + } + return fmt.Sprintf("Packet Core Control Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/id_packetcorecontrolplane_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/id_packetcorecontrolplane_test.go new file mode 100644 index 00000000000..1da3c87424e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/id_packetcorecontrolplane_test.go @@ -0,0 +1,282 @@ +package packetcorecontrolplanereinstall + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +func TestNewPacketCoreControlPlaneID(t *testing.T) { + id := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } +} + +func TestFormatPacketCoreControlPlaneID(t *testing.T) { + actual := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestParsePacketCoreControlPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneId(t *testing.T) { + segments := PacketCoreControlPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/method_packetcorecontrolplanesreinstall.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/method_packetcorecontrolplanesreinstall.go new file mode 100644 index 00000000000..49c39597787 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/method_packetcorecontrolplanesreinstall.go @@ -0,0 +1,71 @@ +package packetcorecontrolplanereinstall + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlanesReinstallOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AsyncOperationStatus +} + +// PacketCoreControlPlanesReinstall ... +func (c PacketCoreControlPlaneReinstallClient) PacketCoreControlPlanesReinstall(ctx context.Context, id PacketCoreControlPlaneId) (result PacketCoreControlPlanesReinstallOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reinstall", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PacketCoreControlPlanesReinstallThenPoll performs PacketCoreControlPlanesReinstall then polls until it's completed +func (c PacketCoreControlPlaneReinstallClient) PacketCoreControlPlanesReinstallThenPoll(ctx context.Context, id PacketCoreControlPlaneId) error { + result, err := c.PacketCoreControlPlanesReinstall(ctx, id) + if err != nil { + return fmt.Errorf("performing PacketCoreControlPlanesReinstall: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PacketCoreControlPlanesReinstall: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_asyncoperationstatus.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_asyncoperationstatus.go new file mode 100644 index 00000000000..3005049a7cc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_asyncoperationstatus.go @@ -0,0 +1,46 @@ +package packetcorecontrolplanereinstall + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AsyncOperationStatus struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + Properties *interface{} `json:"properties,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *AsyncOperationStatus) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AsyncOperationStatus) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_erroradditionalinfo.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_erroradditionalinfo.go new file mode 100644 index 00000000000..ce820e43ff2 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package packetcorecontrolplanereinstall + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_errordetail.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_errordetail.go new file mode 100644 index 00000000000..9525a889d0d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/model_errordetail.go @@ -0,0 +1,12 @@ +package packetcorecontrolplanereinstall + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/version.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/version.go new file mode 100644 index 00000000000..83ccc66aad7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanereinstall/version.go @@ -0,0 +1,12 @@ +package packetcorecontrolplanereinstall + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/packetcorecontrolplanereinstall/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/README.md b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/README.md new file mode 100644 index 00000000000..97283287d02 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/README.md @@ -0,0 +1,32 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback` Documentation + +The `packetcorecontrolplanerollback` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback" +``` + + +### Client Initialization + +```go +client := packetcorecontrolplanerollback.NewPacketCoreControlPlaneRollbackClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCoreControlPlaneRollbackClient.PacketCoreControlPlanesRollback` + +```go +ctx := context.TODO() +id := packetcorecontrolplanerollback.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +if err := client.PacketCoreControlPlanesRollbackThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/client.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/client.go new file mode 100644 index 00000000000..5535806d33e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/client.go @@ -0,0 +1,26 @@ +package packetcorecontrolplanerollback + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneRollbackClient struct { + Client *resourcemanager.Client +} + +func NewPacketCoreControlPlaneRollbackClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCoreControlPlaneRollbackClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "packetcorecontrolplanerollback", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCoreControlPlaneRollbackClient: %+v", err) + } + + return &PacketCoreControlPlaneRollbackClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/id_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/id_packetcorecontrolplane.go new file mode 100644 index 00000000000..9704b0e3cd4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/id_packetcorecontrolplane.go @@ -0,0 +1,130 @@ +package packetcorecontrolplanerollback + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +// PacketCoreControlPlaneId is a struct representing the Resource ID for a Packet Core Control Plane +type PacketCoreControlPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string +} + +// NewPacketCoreControlPlaneID returns a new PacketCoreControlPlaneId struct +func NewPacketCoreControlPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string) PacketCoreControlPlaneId { + return PacketCoreControlPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + } +} + +// ParsePacketCoreControlPlaneID parses 'input' into a PacketCoreControlPlaneId +func ParsePacketCoreControlPlaneID(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneIDInsensitively(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneID checks that 'input' can be parsed as a Packet Core Control Plane ID +func ValidatePacketCoreControlPlaneID(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 := ParsePacketCoreControlPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + } + return fmt.Sprintf("Packet Core Control Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/id_packetcorecontrolplane_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/id_packetcorecontrolplane_test.go new file mode 100644 index 00000000000..726c8a2c073 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/id_packetcorecontrolplane_test.go @@ -0,0 +1,282 @@ +package packetcorecontrolplanerollback + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +func TestNewPacketCoreControlPlaneID(t *testing.T) { + id := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } +} + +func TestFormatPacketCoreControlPlaneID(t *testing.T) { + actual := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestParsePacketCoreControlPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneId(t *testing.T) { + segments := PacketCoreControlPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/method_packetcorecontrolplanesrollback.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/method_packetcorecontrolplanesrollback.go new file mode 100644 index 00000000000..4f0dd28e2ba --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/method_packetcorecontrolplanesrollback.go @@ -0,0 +1,71 @@ +package packetcorecontrolplanerollback + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlanesRollbackOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AsyncOperationStatus +} + +// PacketCoreControlPlanesRollback ... +func (c PacketCoreControlPlaneRollbackClient) PacketCoreControlPlanesRollback(ctx context.Context, id PacketCoreControlPlaneId) (result PacketCoreControlPlanesRollbackOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/rollback", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PacketCoreControlPlanesRollbackThenPoll performs PacketCoreControlPlanesRollback then polls until it's completed +func (c PacketCoreControlPlaneRollbackClient) PacketCoreControlPlanesRollbackThenPoll(ctx context.Context, id PacketCoreControlPlaneId) error { + result, err := c.PacketCoreControlPlanesRollback(ctx, id) + if err != nil { + return fmt.Errorf("performing PacketCoreControlPlanesRollback: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PacketCoreControlPlanesRollback: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_asyncoperationstatus.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_asyncoperationstatus.go new file mode 100644 index 00000000000..b09f097d0c9 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_asyncoperationstatus.go @@ -0,0 +1,46 @@ +package packetcorecontrolplanerollback + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AsyncOperationStatus struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + Properties *interface{} `json:"properties,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *AsyncOperationStatus) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AsyncOperationStatus) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_erroradditionalinfo.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_erroradditionalinfo.go new file mode 100644 index 00000000000..275358096cf --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package packetcorecontrolplanerollback + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_errordetail.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_errordetail.go new file mode 100644 index 00000000000..d573d527572 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/model_errordetail.go @@ -0,0 +1,12 @@ +package packetcorecontrolplanerollback + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/version.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/version.go new file mode 100644 index 00000000000..322915cb062 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanerollback/version.go @@ -0,0 +1,12 @@ +package packetcorecontrolplanerollback + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/packetcorecontrolplanerollback/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/README.md b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/README.md new file mode 100644 index 00000000000..606178717b2 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/README.md @@ -0,0 +1,55 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes` Documentation + +The `packetcorecontrolplanes` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes" +``` + + +### Client Initialization + +```go +client := packetcorecontrolplanes.NewPacketCoreControlPlanesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCoreControlPlanesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PacketCoreControlPlanesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/client.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/client.go new file mode 100644 index 00000000000..c622dd3046c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/client.go @@ -0,0 +1,26 @@ +package packetcorecontrolplanes + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlanesClient struct { + Client *resourcemanager.Client +} + +func NewPacketCoreControlPlanesClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCoreControlPlanesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "packetcorecontrolplanes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCoreControlPlanesClient: %+v", err) + } + + return &PacketCoreControlPlanesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/constants.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/constants.go new file mode 100644 index 00000000000..0c65437c7e3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/constants.go @@ -0,0 +1,580 @@ +package packetcorecontrolplanes + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationType string + +const ( + AuthenticationTypeAAD AuthenticationType = "AAD" + AuthenticationTypePassword AuthenticationType = "Password" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeAAD), + string(AuthenticationTypePassword), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "aad": AuthenticationTypeAAD, + "password": AuthenticationTypePassword, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type BillingSku string + +const ( + BillingSkuGFive BillingSku = "G5" + BillingSkuGOne BillingSku = "G1" + BillingSkuGOneZero BillingSku = "G10" + BillingSkuGTwo BillingSku = "G2" + BillingSkuGZero BillingSku = "G0" +) + +func PossibleValuesForBillingSku() []string { + return []string{ + string(BillingSkuGFive), + string(BillingSkuGOne), + string(BillingSkuGOneZero), + string(BillingSkuGTwo), + string(BillingSkuGZero), + } +} + +func (s *BillingSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBillingSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBillingSku(input string) (*BillingSku, error) { + vals := map[string]BillingSku{ + "g5": BillingSkuGFive, + "g1": BillingSkuGOne, + "g10": BillingSkuGOneZero, + "g2": BillingSkuGTwo, + "g0": BillingSkuGZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BillingSku(input) + return &out, nil +} + +type CertificateProvisioningState string + +const ( + CertificateProvisioningStateFailed CertificateProvisioningState = "Failed" + CertificateProvisioningStateNotProvisioned CertificateProvisioningState = "NotProvisioned" + CertificateProvisioningStateProvisioned CertificateProvisioningState = "Provisioned" +) + +func PossibleValuesForCertificateProvisioningState() []string { + return []string{ + string(CertificateProvisioningStateFailed), + string(CertificateProvisioningStateNotProvisioned), + string(CertificateProvisioningStateProvisioned), + } +} + +func (s *CertificateProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProvisioningState(input string) (*CertificateProvisioningState, error) { + vals := map[string]CertificateProvisioningState{ + "failed": CertificateProvisioningStateFailed, + "notprovisioned": CertificateProvisioningStateNotProvisioned, + "provisioned": CertificateProvisioningStateProvisioned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProvisioningState(input) + return &out, nil +} + +type CoreNetworkType string + +const ( + CoreNetworkTypeEPC CoreNetworkType = "EPC" + CoreNetworkTypeEPCPositiveFiveGC CoreNetworkType = "EPC + 5GC" + CoreNetworkTypeFiveGC CoreNetworkType = "5GC" +) + +func PossibleValuesForCoreNetworkType() []string { + return []string{ + string(CoreNetworkTypeEPC), + string(CoreNetworkTypeEPCPositiveFiveGC), + string(CoreNetworkTypeFiveGC), + } +} + +func (s *CoreNetworkType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCoreNetworkType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCoreNetworkType(input string) (*CoreNetworkType, error) { + vals := map[string]CoreNetworkType{ + "epc": CoreNetworkTypeEPC, + "epc + 5gc": CoreNetworkTypeEPCPositiveFiveGC, + "5gc": CoreNetworkTypeFiveGC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CoreNetworkType(input) + return &out, nil +} + +type DesiredInstallationState string + +const ( + DesiredInstallationStateInstalled DesiredInstallationState = "Installed" + DesiredInstallationStateUninstalled DesiredInstallationState = "Uninstalled" +) + +func PossibleValuesForDesiredInstallationState() []string { + return []string{ + string(DesiredInstallationStateInstalled), + string(DesiredInstallationStateUninstalled), + } +} + +func (s *DesiredInstallationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDesiredInstallationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDesiredInstallationState(input string) (*DesiredInstallationState, error) { + vals := map[string]DesiredInstallationState{ + "installed": DesiredInstallationStateInstalled, + "uninstalled": DesiredInstallationStateUninstalled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DesiredInstallationState(input) + return &out, nil +} + +type HomeNetworkPrivateKeysProvisioningState string + +const ( + HomeNetworkPrivateKeysProvisioningStateFailed HomeNetworkPrivateKeysProvisioningState = "Failed" + HomeNetworkPrivateKeysProvisioningStateNotProvisioned HomeNetworkPrivateKeysProvisioningState = "NotProvisioned" + HomeNetworkPrivateKeysProvisioningStateProvisioned HomeNetworkPrivateKeysProvisioningState = "Provisioned" +) + +func PossibleValuesForHomeNetworkPrivateKeysProvisioningState() []string { + return []string{ + string(HomeNetworkPrivateKeysProvisioningStateFailed), + string(HomeNetworkPrivateKeysProvisioningStateNotProvisioned), + string(HomeNetworkPrivateKeysProvisioningStateProvisioned), + } +} + +func (s *HomeNetworkPrivateKeysProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHomeNetworkPrivateKeysProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHomeNetworkPrivateKeysProvisioningState(input string) (*HomeNetworkPrivateKeysProvisioningState, error) { + vals := map[string]HomeNetworkPrivateKeysProvisioningState{ + "failed": HomeNetworkPrivateKeysProvisioningStateFailed, + "notprovisioned": HomeNetworkPrivateKeysProvisioningStateNotProvisioned, + "provisioned": HomeNetworkPrivateKeysProvisioningStateProvisioned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HomeNetworkPrivateKeysProvisioningState(input) + return &out, nil +} + +type InstallationReason string + +const ( + InstallationReasonControlPlaneAccessInterfaceHasChanged InstallationReason = "ControlPlaneAccessInterfaceHasChanged" + InstallationReasonControlPlaneAccessVirtualIPvFourAddressesHasChanged InstallationReason = "ControlPlaneAccessVirtualIpv4AddressesHasChanged" + InstallationReasonNoAttachedDataNetworks InstallationReason = "NoAttachedDataNetworks" + InstallationReasonNoPacketCoreDataPlane InstallationReason = "NoPacketCoreDataPlane" + InstallationReasonNoSlices InstallationReason = "NoSlices" + InstallationReasonPublicLandMobileNetworkIdentifierHasChanged InstallationReason = "PublicLandMobileNetworkIdentifierHasChanged" + InstallationReasonUserPlaneAccessInterfaceHasChanged InstallationReason = "UserPlaneAccessInterfaceHasChanged" + InstallationReasonUserPlaneAccessVirtualIPvFourAddressesHasChanged InstallationReason = "UserPlaneAccessVirtualIpv4AddressesHasChanged" + InstallationReasonUserPlaneDataInterfaceHasChanged InstallationReason = "UserPlaneDataInterfaceHasChanged" +) + +func PossibleValuesForInstallationReason() []string { + return []string{ + string(InstallationReasonControlPlaneAccessInterfaceHasChanged), + string(InstallationReasonControlPlaneAccessVirtualIPvFourAddressesHasChanged), + string(InstallationReasonNoAttachedDataNetworks), + string(InstallationReasonNoPacketCoreDataPlane), + string(InstallationReasonNoSlices), + string(InstallationReasonPublicLandMobileNetworkIdentifierHasChanged), + string(InstallationReasonUserPlaneAccessInterfaceHasChanged), + string(InstallationReasonUserPlaneAccessVirtualIPvFourAddressesHasChanged), + string(InstallationReasonUserPlaneDataInterfaceHasChanged), + } +} + +func (s *InstallationReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInstallationReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInstallationReason(input string) (*InstallationReason, error) { + vals := map[string]InstallationReason{ + "controlplaneaccessinterfacehaschanged": InstallationReasonControlPlaneAccessInterfaceHasChanged, + "controlplaneaccessvirtualipv4addresseshaschanged": InstallationReasonControlPlaneAccessVirtualIPvFourAddressesHasChanged, + "noattacheddatanetworks": InstallationReasonNoAttachedDataNetworks, + "nopacketcoredataplane": InstallationReasonNoPacketCoreDataPlane, + "noslices": InstallationReasonNoSlices, + "publiclandmobilenetworkidentifierhaschanged": InstallationReasonPublicLandMobileNetworkIdentifierHasChanged, + "userplaneaccessinterfacehaschanged": InstallationReasonUserPlaneAccessInterfaceHasChanged, + "userplaneaccessvirtualipv4addresseshaschanged": InstallationReasonUserPlaneAccessVirtualIPvFourAddressesHasChanged, + "userplanedatainterfacehaschanged": InstallationReasonUserPlaneDataInterfaceHasChanged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InstallationReason(input) + return &out, nil +} + +type InstallationState string + +const ( + InstallationStateFailed InstallationState = "Failed" + InstallationStateInstalled InstallationState = "Installed" + InstallationStateInstalling InstallationState = "Installing" + InstallationStateReinstalling InstallationState = "Reinstalling" + InstallationStateRollingBack InstallationState = "RollingBack" + InstallationStateUninstalled InstallationState = "Uninstalled" + InstallationStateUninstalling InstallationState = "Uninstalling" + InstallationStateUpdating InstallationState = "Updating" + InstallationStateUpgrading InstallationState = "Upgrading" +) + +func PossibleValuesForInstallationState() []string { + return []string{ + string(InstallationStateFailed), + string(InstallationStateInstalled), + string(InstallationStateInstalling), + string(InstallationStateReinstalling), + string(InstallationStateRollingBack), + string(InstallationStateUninstalled), + string(InstallationStateUninstalling), + string(InstallationStateUpdating), + string(InstallationStateUpgrading), + } +} + +func (s *InstallationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInstallationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInstallationState(input string) (*InstallationState, error) { + vals := map[string]InstallationState{ + "failed": InstallationStateFailed, + "installed": InstallationStateInstalled, + "installing": InstallationStateInstalling, + "reinstalling": InstallationStateReinstalling, + "rollingback": InstallationStateRollingBack, + "uninstalled": InstallationStateUninstalled, + "uninstalling": InstallationStateUninstalling, + "updating": InstallationStateUpdating, + "upgrading": InstallationStateUpgrading, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InstallationState(input) + return &out, nil +} + +type NasEncryptionType string + +const ( + NasEncryptionTypeNEAOneEEAOne NasEncryptionType = "NEA1/EEA1" + NasEncryptionTypeNEATwoEEATwo NasEncryptionType = "NEA2/EEA2" + NasEncryptionTypeNEAZeroEEAZero NasEncryptionType = "NEA0/EEA0" +) + +func PossibleValuesForNasEncryptionType() []string { + return []string{ + string(NasEncryptionTypeNEAOneEEAOne), + string(NasEncryptionTypeNEATwoEEATwo), + string(NasEncryptionTypeNEAZeroEEAZero), + } +} + +func (s *NasEncryptionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNasEncryptionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNasEncryptionType(input string) (*NasEncryptionType, error) { + vals := map[string]NasEncryptionType{ + "nea1/eea1": NasEncryptionTypeNEAOneEEAOne, + "nea2/eea2": NasEncryptionTypeNEATwoEEATwo, + "nea0/eea0": NasEncryptionTypeNEAZeroEEAZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NasEncryptionType(input) + return &out, nil +} + +type PlatformType string + +const ( + PlatformTypeAKSNegativeHCI PlatformType = "AKS-HCI" + PlatformTypeThreePNegativeAZURENegativeSTACKNegativeHCI PlatformType = "3P-AZURE-STACK-HCI" +) + +func PossibleValuesForPlatformType() []string { + return []string{ + string(PlatformTypeAKSNegativeHCI), + string(PlatformTypeThreePNegativeAZURENegativeSTACKNegativeHCI), + } +} + +func (s *PlatformType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePlatformType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePlatformType(input string) (*PlatformType, error) { + vals := map[string]PlatformType{ + "aks-hci": PlatformTypeAKSNegativeHCI, + "3p-azure-stack-hci": PlatformTypeThreePNegativeAZURENegativeSTACKNegativeHCI, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PlatformType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + 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 ReinstallRequired string + +const ( + ReinstallRequiredNotRequired ReinstallRequired = "NotRequired" + ReinstallRequiredRequired ReinstallRequired = "Required" +) + +func PossibleValuesForReinstallRequired() []string { + return []string{ + string(ReinstallRequiredNotRequired), + string(ReinstallRequiredRequired), + } +} + +func (s *ReinstallRequired) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReinstallRequired(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReinstallRequired(input string) (*ReinstallRequired, error) { + vals := map[string]ReinstallRequired{ + "notrequired": ReinstallRequiredNotRequired, + "required": ReinstallRequiredRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReinstallRequired(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/method_listbyresourcegroup.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/method_listbyresourcegroup.go new file mode 100644 index 00000000000..5cbc0e0ab26 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package packetcorecontrolplanes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PacketCoreControlPlane +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PacketCoreControlPlane +} + +// ListByResourceGroup ... +func (c PacketCoreControlPlanesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PacketCoreControlPlane `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c PacketCoreControlPlanesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, PacketCoreControlPlaneOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PacketCoreControlPlanesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate PacketCoreControlPlaneOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]PacketCoreControlPlane, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/method_listbysubscription.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/method_listbysubscription.go new file mode 100644 index 00000000000..b528ec05b9d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/method_listbysubscription.go @@ -0,0 +1,92 @@ +package packetcorecontrolplanes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PacketCoreControlPlane +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PacketCoreControlPlane +} + +// ListBySubscription ... +func (c PacketCoreControlPlanesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PacketCoreControlPlane `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c PacketCoreControlPlanesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, PacketCoreControlPlaneOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PacketCoreControlPlanesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PacketCoreControlPlaneOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]PacketCoreControlPlane, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_asyncoperationid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_asyncoperationid.go new file mode 100644 index 00000000000..c0d6aa4a4ee --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_asyncoperationid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AsyncOperationId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_azurestackedgedeviceresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_azurestackedgedeviceresourceid.go new file mode 100644 index 00000000000..1b7556d8526 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_azurestackedgedeviceresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStackEdgeDeviceResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_azurestackhciclusterresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_azurestackhciclusterresourceid.go new file mode 100644 index 00000000000..5de58cf4fb7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_azurestackhciclusterresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStackHCIClusterResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_certificateprovisioning.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_certificateprovisioning.go new file mode 100644 index 00000000000..c12f9f1c9ab --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_certificateprovisioning.go @@ -0,0 +1,9 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProvisioning struct { + Reason *string `json:"reason,omitempty"` + State *CertificateProvisioningState `json:"state,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_connectedclusterresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_connectedclusterresourceid.go new file mode 100644 index 00000000000..1149bf9a85b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_connectedclusterresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedClusterResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_customlocationresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_customlocationresourceid.go new file mode 100644 index 00000000000..eaecf2b8c00 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_customlocationresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomLocationResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_diagnosticsuploadconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_diagnosticsuploadconfiguration.go new file mode 100644 index 00000000000..7f971c9a784 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_diagnosticsuploadconfiguration.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsUploadConfiguration struct { + StorageAccountContainerUrl string `json:"storageAccountContainerUrl"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_eventhubconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_eventhubconfiguration.go new file mode 100644 index 00000000000..e52fdca6cdd --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_eventhubconfiguration.go @@ -0,0 +1,9 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventHubConfiguration struct { + Id string `json:"id"` + ReportingInterval *int64 `json:"reportingInterval,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_homenetworkprivatekeysprovisioning.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_homenetworkprivatekeysprovisioning.go new file mode 100644 index 00000000000..4de03660d01 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_homenetworkprivatekeysprovisioning.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HomeNetworkPrivateKeysProvisioning struct { + State HomeNetworkPrivateKeysProvisioningState `json:"state"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_httpsservercertificate.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_httpsservercertificate.go new file mode 100644 index 00000000000..f541aa9fb6e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_httpsservercertificate.go @@ -0,0 +1,9 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSServerCertificate struct { + CertificateUrl string `json:"certificateUrl"` + Provisioning *CertificateProvisioning `json:"provisioning,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_installation.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_installation.go new file mode 100644 index 00000000000..fc1a17a1c8c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_installation.go @@ -0,0 +1,12 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Installation struct { + DesiredState *DesiredInstallationState `json:"desiredState,omitempty"` + Operation *AsyncOperationId `json:"operation,omitempty"` + Reasons *[]InstallationReason `json:"reasons,omitempty"` + ReinstallRequired *ReinstallRequired `json:"reinstallRequired,omitempty"` + State *InstallationState `json:"state,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_interfaceproperties.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_interfaceproperties.go new file mode 100644 index 00000000000..30f30a06f1e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_interfaceproperties.go @@ -0,0 +1,14 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InterfaceProperties struct { + BfdIPv4Endpoints *[]string `json:"bfdIpv4Endpoints,omitempty"` + IPv4Address *string `json:"ipv4Address,omitempty"` + IPv4AddressList *[]string `json:"ipv4AddressList,omitempty"` + IPv4Gateway *string `json:"ipv4Gateway,omitempty"` + IPv4Subnet *string `json:"ipv4Subnet,omitempty"` + Name *string `json:"name,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_localdiagnosticsaccessconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_localdiagnosticsaccessconfiguration.go new file mode 100644 index 00000000000..a5f4dd20e64 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_localdiagnosticsaccessconfiguration.go @@ -0,0 +1,9 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalDiagnosticsAccessConfiguration struct { + AuthenticationType AuthenticationType `json:"authenticationType"` + HTTPSServerCertificate *HTTPSServerCertificate `json:"httpsServerCertificate,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_nasrerouteconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_nasrerouteconfiguration.go new file mode 100644 index 00000000000..d5073e2e095 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_nasrerouteconfiguration.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NASRerouteConfiguration struct { + MacroMmeGroupId int64 `json:"macroMmeGroupId"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_packetcorecontrolplane.go new file mode 100644 index 00000000000..d508cf69846 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_packetcorecontrolplane.go @@ -0,0 +1,20 @@ +package packetcorecontrolplanes + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlane struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties PacketCoreControlPlanePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_packetcorecontrolplanepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_packetcorecontrolplanepropertiesformat.go new file mode 100644 index 00000000000..b586e33822e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_packetcorecontrolplanepropertiesformat.go @@ -0,0 +1,26 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlanePropertiesFormat struct { + ControlPlaneAccessInterface InterfaceProperties `json:"controlPlaneAccessInterface"` + ControlPlaneAccessVirtualIPv4Addresses *[]string `json:"controlPlaneAccessVirtualIpv4Addresses,omitempty"` + CoreNetworkTechnology *CoreNetworkType `json:"coreNetworkTechnology,omitempty"` + DiagnosticsUpload *DiagnosticsUploadConfiguration `json:"diagnosticsUpload,omitempty"` + EventHub *EventHubConfiguration `json:"eventHub,omitempty"` + HomeNetworkPrivateKeysProvisioning *HomeNetworkPrivateKeysProvisioning `json:"homeNetworkPrivateKeysProvisioning,omitempty"` + Installation *Installation `json:"installation,omitempty"` + InstalledVersion *string `json:"installedVersion,omitempty"` + InteropSettings *interface{} `json:"interopSettings,omitempty"` + LocalDiagnosticsAccess LocalDiagnosticsAccessConfiguration `json:"localDiagnosticsAccess"` + Platform PlatformConfiguration `json:"platform"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RollbackVersion *string `json:"rollbackVersion,omitempty"` + Signaling *SignalingConfiguration `json:"signaling,omitempty"` + Sites []SiteResourceId `json:"sites"` + Sku BillingSku `json:"sku"` + UeMtu *int64 `json:"ueMtu,omitempty"` + UserConsent *UserConsentConfiguration `json:"userConsent,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_platformconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_platformconfiguration.go new file mode 100644 index 00000000000..9f267f64af2 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_platformconfiguration.go @@ -0,0 +1,13 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlatformConfiguration struct { + AzureStackEdgeDevice *AzureStackEdgeDeviceResourceId `json:"azureStackEdgeDevice,omitempty"` + AzureStackEdgeDevices *[]AzureStackEdgeDeviceResourceId `json:"azureStackEdgeDevices,omitempty"` + AzureStackHciCluster *AzureStackHCIClusterResourceId `json:"azureStackHciCluster,omitempty"` + ConnectedCluster *ConnectedClusterResourceId `json:"connectedCluster,omitempty"` + CustomLocation *CustomLocationResourceId `json:"customLocation,omitempty"` + Type PlatformType `json:"type"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_signalingconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_signalingconfiguration.go new file mode 100644 index 00000000000..df65693b8c4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_signalingconfiguration.go @@ -0,0 +1,9 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignalingConfiguration struct { + NasEncryption *[]NasEncryptionType `json:"nasEncryption,omitempty"` + NasReroute *NASRerouteConfiguration `json:"nasReroute,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_siteresourceid.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_siteresourceid.go new file mode 100644 index 00000000000..c0702efdcb1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_siteresourceid.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_userconsentconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_userconsentconfiguration.go new file mode 100644 index 00000000000..77cf5b2250f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/model_userconsentconfiguration.go @@ -0,0 +1,8 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserConsentConfiguration struct { + AllowSupportTelemetryAccess *bool `json:"allowSupportTelemetryAccess,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/predicates.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/predicates.go new file mode 100644 index 00000000000..66e19af8dbc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/predicates.go @@ -0,0 +1,32 @@ +package packetcorecontrolplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p PacketCoreControlPlaneOperationPredicate) Matches(input PacketCoreControlPlane) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/version.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/version.go new file mode 100644 index 00000000000..0ab040e0a85 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplanes/version.go @@ -0,0 +1,12 @@ +package packetcorecontrolplanes + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/packetcorecontrolplanes/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/README.md b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/README.md new file mode 100644 index 00000000000..79d9ee21413 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/README.md @@ -0,0 +1,87 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion` Documentation + +The `packetcorecontrolplaneversion` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion" +``` + + +### Client Initialization + +```go +client := packetcorecontrolplaneversion.NewPacketCoreControlPlaneVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCoreControlPlaneVersionClient.Get` + +```go +ctx := context.TODO() +id := packetcorecontrolplaneversion.NewPacketCoreControlPlaneVersionID("packetCoreControlPlaneVersionValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PacketCoreControlPlaneVersionClient.GetBySubscription` + +```go +ctx := context.TODO() +id := packetcorecontrolplaneversion.NewProviderPacketCoreControlPlaneVersionID("12345678-1234-9876-4563-123456789012", "packetCoreControlPlaneVersionValue") + +read, err := client.GetBySubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PacketCoreControlPlaneVersionClient.List` + +```go +ctx := context.TODO() + + +// alternatively `client.List(ctx)` can be used to do batched pagination +items, err := client.ListComplete(ctx) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PacketCoreControlPlaneVersionClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/client.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/client.go new file mode 100644 index 00000000000..8467e64af60 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/client.go @@ -0,0 +1,26 @@ +package packetcorecontrolplaneversion + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneVersionClient struct { + Client *resourcemanager.Client +} + +func NewPacketCoreControlPlaneVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCoreControlPlaneVersionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "packetcorecontrolplaneversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCoreControlPlaneVersionClient: %+v", err) + } + + return &PacketCoreControlPlaneVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/constants.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/constants.go new file mode 100644 index 00000000000..a65a26c40f6 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/constants.go @@ -0,0 +1,242 @@ +package packetcorecontrolplaneversion + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ObsoleteVersion string + +const ( + ObsoleteVersionNotObsolete ObsoleteVersion = "NotObsolete" + ObsoleteVersionObsolete ObsoleteVersion = "Obsolete" +) + +func PossibleValuesForObsoleteVersion() []string { + return []string{ + string(ObsoleteVersionNotObsolete), + string(ObsoleteVersionObsolete), + } +} + +func (s *ObsoleteVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseObsoleteVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseObsoleteVersion(input string) (*ObsoleteVersion, error) { + vals := map[string]ObsoleteVersion{ + "notobsolete": ObsoleteVersionNotObsolete, + "obsolete": ObsoleteVersionObsolete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ObsoleteVersion(input) + return &out, nil +} + +type PlatformType string + +const ( + PlatformTypeAKSNegativeHCI PlatformType = "AKS-HCI" + PlatformTypeThreePNegativeAZURENegativeSTACKNegativeHCI PlatformType = "3P-AZURE-STACK-HCI" +) + +func PossibleValuesForPlatformType() []string { + return []string{ + string(PlatformTypeAKSNegativeHCI), + string(PlatformTypeThreePNegativeAZURENegativeSTACKNegativeHCI), + } +} + +func (s *PlatformType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePlatformType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePlatformType(input string) (*PlatformType, error) { + vals := map[string]PlatformType{ + "aks-hci": PlatformTypeAKSNegativeHCI, + "3p-azure-stack-hci": PlatformTypeThreePNegativeAZURENegativeSTACKNegativeHCI, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PlatformType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + 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 RecommendedVersion string + +const ( + RecommendedVersionNotRecommended RecommendedVersion = "NotRecommended" + RecommendedVersionRecommended RecommendedVersion = "Recommended" +) + +func PossibleValuesForRecommendedVersion() []string { + return []string{ + string(RecommendedVersionNotRecommended), + string(RecommendedVersionRecommended), + } +} + +func (s *RecommendedVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecommendedVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecommendedVersion(input string) (*RecommendedVersion, error) { + vals := map[string]RecommendedVersion{ + "notrecommended": RecommendedVersionNotRecommended, + "recommended": RecommendedVersionRecommended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecommendedVersion(input) + return &out, nil +} + +type VersionState string + +const ( + VersionStateActive VersionState = "Active" + VersionStateDeprecated VersionState = "Deprecated" + VersionStatePreview VersionState = "Preview" + VersionStateUnknown VersionState = "Unknown" + VersionStateValidating VersionState = "Validating" + VersionStateValidationFailed VersionState = "ValidationFailed" +) + +func PossibleValuesForVersionState() []string { + return []string{ + string(VersionStateActive), + string(VersionStateDeprecated), + string(VersionStatePreview), + string(VersionStateUnknown), + string(VersionStateValidating), + string(VersionStateValidationFailed), + } +} + +func (s *VersionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVersionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVersionState(input string) (*VersionState, error) { + vals := map[string]VersionState{ + "active": VersionStateActive, + "deprecated": VersionStateDeprecated, + "preview": VersionStatePreview, + "unknown": VersionStateUnknown, + "validating": VersionStateValidating, + "validationfailed": VersionStateValidationFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VersionState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_packetcorecontrolplaneversion.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_packetcorecontrolplaneversion.go new file mode 100644 index 00000000000..3b635613407 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_packetcorecontrolplaneversion.go @@ -0,0 +1,112 @@ +package packetcorecontrolplaneversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneVersionId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneVersionId{} + +// PacketCoreControlPlaneVersionId is a struct representing the Resource ID for a Packet Core Control Plane Version +type PacketCoreControlPlaneVersionId struct { + PacketCoreControlPlaneVersionName string +} + +// NewPacketCoreControlPlaneVersionID returns a new PacketCoreControlPlaneVersionId struct +func NewPacketCoreControlPlaneVersionID(packetCoreControlPlaneVersionName string) PacketCoreControlPlaneVersionId { + return PacketCoreControlPlaneVersionId{ + PacketCoreControlPlaneVersionName: packetCoreControlPlaneVersionName, + } +} + +// ParsePacketCoreControlPlaneVersionID parses 'input' into a PacketCoreControlPlaneVersionId +func ParsePacketCoreControlPlaneVersionID(input string) (*PacketCoreControlPlaneVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneVersionIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneVersionId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneVersionIDInsensitively(input string) (*PacketCoreControlPlaneVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PacketCoreControlPlaneVersionName, ok = input.Parsed["packetCoreControlPlaneVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneVersionName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneVersionID checks that 'input' can be parsed as a Packet Core Control Plane Version ID +func ValidatePacketCoreControlPlaneVersionID(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 := ParsePacketCoreControlPlaneVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane Version ID +func (id PacketCoreControlPlaneVersionId) ID() string { + fmtString := "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/%s" + return fmt.Sprintf(fmtString, id.PacketCoreControlPlaneVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane Version ID +func (id PacketCoreControlPlaneVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlaneVersions", "packetCoreControlPlaneVersions", "packetCoreControlPlaneVersions"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneVersionName", "packetCoreControlPlaneVersionValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane Version ID +func (id PacketCoreControlPlaneVersionId) String() string { + components := []string{ + fmt.Sprintf("Packet Core Control Plane Version Name: %q", id.PacketCoreControlPlaneVersionName), + } + return fmt.Sprintf("Packet Core Control Plane Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_packetcorecontrolplaneversion_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_packetcorecontrolplaneversion_test.go new file mode 100644 index 00000000000..cf37389f9b6 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_packetcorecontrolplaneversion_test.go @@ -0,0 +1,192 @@ +package packetcorecontrolplaneversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneVersionId{} + +func TestNewPacketCoreControlPlaneVersionID(t *testing.T) { + id := NewPacketCoreControlPlaneVersionID("packetCoreControlPlaneVersionValue") + + if id.PacketCoreControlPlaneVersionName != "packetCoreControlPlaneVersionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneVersionName'", id.PacketCoreControlPlaneVersionName, "packetCoreControlPlaneVersionValue") + } +} + +func TestFormatPacketCoreControlPlaneVersionID(t *testing.T) { + actual := NewPacketCoreControlPlaneVersionID("packetCoreControlPlaneVersionValue").ID() + expected := "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue", + Expected: &PacketCoreControlPlaneVersionId{ + PacketCoreControlPlaneVersionName: "packetCoreControlPlaneVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneVersionID(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.PacketCoreControlPlaneVersionName != v.Expected.PacketCoreControlPlaneVersionName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneVersionName", v.Expected.PacketCoreControlPlaneVersionName, actual.PacketCoreControlPlaneVersionName) + } + + } +} + +func TestParsePacketCoreControlPlaneVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue", + Expected: &PacketCoreControlPlaneVersionId{ + PacketCoreControlPlaneVersionName: "packetCoreControlPlaneVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEvErSiOnS/pAcKeTcOrEcOnTrOlPlAnEvErSiOnVaLuE", + Expected: &PacketCoreControlPlaneVersionId{ + PacketCoreControlPlaneVersionName: "pAcKeTcOrEcOnTrOlPlAnEvErSiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEvErSiOnS/pAcKeTcOrEcOnTrOlPlAnEvErSiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneVersionIDInsensitively(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.PacketCoreControlPlaneVersionName != v.Expected.PacketCoreControlPlaneVersionName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneVersionName", v.Expected.PacketCoreControlPlaneVersionName, actual.PacketCoreControlPlaneVersionName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneVersionId(t *testing.T) { + segments := PacketCoreControlPlaneVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_providerpacketcorecontrolplaneversion.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_providerpacketcorecontrolplaneversion.go new file mode 100644 index 00000000000..a377ac5e588 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_providerpacketcorecontrolplaneversion.go @@ -0,0 +1,121 @@ +package packetcorecontrolplaneversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderPacketCoreControlPlaneVersionId{}) +} + +var _ resourceids.ResourceId = &ProviderPacketCoreControlPlaneVersionId{} + +// ProviderPacketCoreControlPlaneVersionId is a struct representing the Resource ID for a Provider Packet Core Control Plane Version +type ProviderPacketCoreControlPlaneVersionId struct { + SubscriptionId string + PacketCoreControlPlaneVersionName string +} + +// NewProviderPacketCoreControlPlaneVersionID returns a new ProviderPacketCoreControlPlaneVersionId struct +func NewProviderPacketCoreControlPlaneVersionID(subscriptionId string, packetCoreControlPlaneVersionName string) ProviderPacketCoreControlPlaneVersionId { + return ProviderPacketCoreControlPlaneVersionId{ + SubscriptionId: subscriptionId, + PacketCoreControlPlaneVersionName: packetCoreControlPlaneVersionName, + } +} + +// ParseProviderPacketCoreControlPlaneVersionID parses 'input' into a ProviderPacketCoreControlPlaneVersionId +func ParseProviderPacketCoreControlPlaneVersionID(input string) (*ProviderPacketCoreControlPlaneVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPacketCoreControlPlaneVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPacketCoreControlPlaneVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderPacketCoreControlPlaneVersionIDInsensitively parses 'input' case-insensitively into a ProviderPacketCoreControlPlaneVersionId +// note: this method should only be used for API response data and not user input +func ParseProviderPacketCoreControlPlaneVersionIDInsensitively(input string) (*ProviderPacketCoreControlPlaneVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderPacketCoreControlPlaneVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderPacketCoreControlPlaneVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderPacketCoreControlPlaneVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PacketCoreControlPlaneVersionName, ok = input.Parsed["packetCoreControlPlaneVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneVersionName", input) + } + + return nil +} + +// ValidateProviderPacketCoreControlPlaneVersionID checks that 'input' can be parsed as a Provider Packet Core Control Plane Version ID +func ValidateProviderPacketCoreControlPlaneVersionID(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 := ParseProviderPacketCoreControlPlaneVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Packet Core Control Plane Version ID +func (id ProviderPacketCoreControlPlaneVersionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PacketCoreControlPlaneVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Packet Core Control Plane Version ID +func (id ProviderPacketCoreControlPlaneVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlaneVersions", "packetCoreControlPlaneVersions", "packetCoreControlPlaneVersions"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneVersionName", "packetCoreControlPlaneVersionValue"), + } +} + +// String returns a human-readable description of this Provider Packet Core Control Plane Version ID +func (id ProviderPacketCoreControlPlaneVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Packet Core Control Plane Version Name: %q", id.PacketCoreControlPlaneVersionName), + } + return fmt.Sprintf("Provider Packet Core Control Plane Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_providerpacketcorecontrolplaneversion_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_providerpacketcorecontrolplaneversion_test.go new file mode 100644 index 00000000000..63f01bbb065 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/id_providerpacketcorecontrolplaneversion_test.go @@ -0,0 +1,237 @@ +package packetcorecontrolplaneversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderPacketCoreControlPlaneVersionId{} + +func TestNewProviderPacketCoreControlPlaneVersionID(t *testing.T) { + id := NewProviderPacketCoreControlPlaneVersionID("12345678-1234-9876-4563-123456789012", "packetCoreControlPlaneVersionValue") + + 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.PacketCoreControlPlaneVersionName != "packetCoreControlPlaneVersionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneVersionName'", id.PacketCoreControlPlaneVersionName, "packetCoreControlPlaneVersionValue") + } +} + +func TestFormatProviderPacketCoreControlPlaneVersionID(t *testing.T) { + actual := NewProviderPacketCoreControlPlaneVersionID("12345678-1234-9876-4563-123456789012", "packetCoreControlPlaneVersionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderPacketCoreControlPlaneVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPacketCoreControlPlaneVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue", + Expected: &ProviderPacketCoreControlPlaneVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PacketCoreControlPlaneVersionName: "packetCoreControlPlaneVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPacketCoreControlPlaneVersionID(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.PacketCoreControlPlaneVersionName != v.Expected.PacketCoreControlPlaneVersionName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneVersionName", v.Expected.PacketCoreControlPlaneVersionName, actual.PacketCoreControlPlaneVersionName) + } + + } +} + +func TestParseProviderPacketCoreControlPlaneVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderPacketCoreControlPlaneVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue", + Expected: &ProviderPacketCoreControlPlaneVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PacketCoreControlPlaneVersionName: "packetCoreControlPlaneVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions/packetCoreControlPlaneVersionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEvErSiOnS/pAcKeTcOrEcOnTrOlPlAnEvErSiOnVaLuE", + Expected: &ProviderPacketCoreControlPlaneVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PacketCoreControlPlaneVersionName: "pAcKeTcOrEcOnTrOlPlAnEvErSiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEvErSiOnS/pAcKeTcOrEcOnTrOlPlAnEvErSiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderPacketCoreControlPlaneVersionIDInsensitively(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.PacketCoreControlPlaneVersionName != v.Expected.PacketCoreControlPlaneVersionName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneVersionName", v.Expected.PacketCoreControlPlaneVersionName, actual.PacketCoreControlPlaneVersionName) + } + + } +} + +func TestSegmentsForProviderPacketCoreControlPlaneVersionId(t *testing.T) { + segments := ProviderPacketCoreControlPlaneVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderPacketCoreControlPlaneVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_get.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_get.go new file mode 100644 index 00000000000..86ea0a903b5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_get.go @@ -0,0 +1,54 @@ +package packetcorecontrolplaneversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PacketCoreControlPlaneVersion +} + +// Get ... +func (c PacketCoreControlPlaneVersionClient) Get(ctx context.Context, id PacketCoreControlPlaneVersionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PacketCoreControlPlaneVersion + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_getbysubscription.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_getbysubscription.go new file mode 100644 index 00000000000..164ea846640 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_getbysubscription.go @@ -0,0 +1,54 @@ +package packetcorecontrolplaneversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PacketCoreControlPlaneVersion +} + +// GetBySubscription ... +func (c PacketCoreControlPlaneVersionClient) GetBySubscription(ctx context.Context, id ProviderPacketCoreControlPlaneVersionId) (result GetBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PacketCoreControlPlaneVersion + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_list.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_list.go new file mode 100644 index 00000000000..d9f607025fc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_list.go @@ -0,0 +1,91 @@ +package packetcorecontrolplaneversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PacketCoreControlPlaneVersion +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PacketCoreControlPlaneVersion +} + +// List ... +func (c PacketCoreControlPlaneVersionClient) List(ctx context.Context) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PacketCoreControlPlaneVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PacketCoreControlPlaneVersionClient) ListComplete(ctx context.Context) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, PacketCoreControlPlaneVersionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PacketCoreControlPlaneVersionClient) ListCompleteMatchingPredicate(ctx context.Context, predicate PacketCoreControlPlaneVersionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PacketCoreControlPlaneVersion, 0) + + resp, err := c.List(ctx) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_listbysubscription.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_listbysubscription.go new file mode 100644 index 00000000000..07a15d03d71 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/method_listbysubscription.go @@ -0,0 +1,92 @@ +package packetcorecontrolplaneversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PacketCoreControlPlaneVersion +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PacketCoreControlPlaneVersion +} + +// ListBySubscription ... +func (c PacketCoreControlPlaneVersionClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.MobileNetwork/packetCoreControlPlaneVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PacketCoreControlPlaneVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c PacketCoreControlPlaneVersionClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, PacketCoreControlPlaneVersionOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PacketCoreControlPlaneVersionClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PacketCoreControlPlaneVersionOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]PacketCoreControlPlaneVersion, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_packetcorecontrolplaneversion.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_packetcorecontrolplaneversion.go new file mode 100644 index 00000000000..b43b095f067 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_packetcorecontrolplaneversion.go @@ -0,0 +1,16 @@ +package packetcorecontrolplaneversion + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties PacketCoreControlPlaneVersionPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_packetcorecontrolplaneversionpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_packetcorecontrolplaneversionpropertiesformat.go new file mode 100644 index 00000000000..c81ee580fae --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_packetcorecontrolplaneversionpropertiesformat.go @@ -0,0 +1,9 @@ +package packetcorecontrolplaneversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneVersionPropertiesFormat struct { + Platforms *[]Platform `json:"platforms,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_platform.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_platform.go new file mode 100644 index 00000000000..be217a59e39 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/model_platform.go @@ -0,0 +1,14 @@ +package packetcorecontrolplaneversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Platform struct { + HaUpgradesAvailable *[]string `json:"haUpgradesAvailable,omitempty"` + MaximumPlatformSoftwareVersion *string `json:"maximumPlatformSoftwareVersion,omitempty"` + MinimumPlatformSoftwareVersion *string `json:"minimumPlatformSoftwareVersion,omitempty"` + ObsoleteVersion *ObsoleteVersion `json:"obsoleteVersion,omitempty"` + PlatformType *PlatformType `json:"platformType,omitempty"` + RecommendedVersion *RecommendedVersion `json:"recommendedVersion,omitempty"` + VersionState *VersionState `json:"versionState,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/predicates.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/predicates.go new file mode 100644 index 00000000000..63260f5ad22 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/predicates.go @@ -0,0 +1,27 @@ +package packetcorecontrolplaneversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PacketCoreControlPlaneVersionOperationPredicate) Matches(input PacketCoreControlPlaneVersion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/version.go b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/version.go new file mode 100644 index 00000000000..45cb8bb758a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcorecontrolplaneversion/version.go @@ -0,0 +1,12 @@ +package packetcorecontrolplaneversion + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/packetcorecontrolplaneversion/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/README.md b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/README.md new file mode 100644 index 00000000000..f65edc11c15 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane` Documentation + +The `packetcoredataplane` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane" +``` + + +### Client Initialization + +```go +client := packetcoredataplane.NewPacketCoreDataPlaneClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCoreDataPlaneClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := packetcoredataplane.NewPacketCoreDataPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue") + +payload := packetcoredataplane.PacketCoreDataPlane{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PacketCoreDataPlaneClient.Delete` + +```go +ctx := context.TODO() +id := packetcoredataplane.NewPacketCoreDataPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PacketCoreDataPlaneClient.Get` + +```go +ctx := context.TODO() +id := packetcoredataplane.NewPacketCoreDataPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PacketCoreDataPlaneClient.UpdateTags` + +```go +ctx := context.TODO() +id := packetcoredataplane.NewPacketCoreDataPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue") + +payload := packetcoredataplane.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/client.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/client.go new file mode 100644 index 00000000000..dc550d86f7a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/client.go @@ -0,0 +1,26 @@ +package packetcoredataplane + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreDataPlaneClient struct { + Client *resourcemanager.Client +} + +func NewPacketCoreDataPlaneClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCoreDataPlaneClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "packetcoredataplane", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCoreDataPlaneClient: %+v", err) + } + + return &PacketCoreDataPlaneClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/constants.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/constants.go new file mode 100644 index 00000000000..fc7505c20c1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/constants.go @@ -0,0 +1,66 @@ +package packetcoredataplane + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/id_packetcoredataplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/id_packetcoredataplane.go new file mode 100644 index 00000000000..719ad90ad50 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/id_packetcoredataplane.go @@ -0,0 +1,139 @@ +package packetcoredataplane + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreDataPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreDataPlaneId{} + +// PacketCoreDataPlaneId is a struct representing the Resource ID for a Packet Core Data Plane +type PacketCoreDataPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string + PacketCoreDataPlaneName string +} + +// NewPacketCoreDataPlaneID returns a new PacketCoreDataPlaneId struct +func NewPacketCoreDataPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string) PacketCoreDataPlaneId { + return PacketCoreDataPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + PacketCoreDataPlaneName: packetCoreDataPlaneName, + } +} + +// ParsePacketCoreDataPlaneID parses 'input' into a PacketCoreDataPlaneId +func ParsePacketCoreDataPlaneID(input string) (*PacketCoreDataPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreDataPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreDataPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreDataPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreDataPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreDataPlaneIDInsensitively(input string) (*PacketCoreDataPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreDataPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreDataPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreDataPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + if id.PacketCoreDataPlaneName, ok = input.Parsed["packetCoreDataPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreDataPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreDataPlaneID checks that 'input' can be parsed as a Packet Core Data Plane ID +func ValidatePacketCoreDataPlaneID(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 := ParsePacketCoreDataPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Data Plane ID +func (id PacketCoreDataPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s/packetCoreDataPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName, id.PacketCoreDataPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Data Plane ID +func (id PacketCoreDataPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + resourceids.StaticSegment("staticPacketCoreDataPlanes", "packetCoreDataPlanes", "packetCoreDataPlanes"), + resourceids.UserSpecifiedSegment("packetCoreDataPlaneName", "packetCoreDataPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Data Plane ID +func (id PacketCoreDataPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + fmt.Sprintf("Packet Core Data Plane Name: %q", id.PacketCoreDataPlaneName), + } + return fmt.Sprintf("Packet Core Data Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/id_packetcoredataplane_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/id_packetcoredataplane_test.go new file mode 100644 index 00000000000..af9c2187a66 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/id_packetcoredataplane_test.go @@ -0,0 +1,327 @@ +package packetcoredataplane + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreDataPlaneId{} + +func TestNewPacketCoreDataPlaneID(t *testing.T) { + id := NewPacketCoreDataPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } + + if id.PacketCoreDataPlaneName != "packetCoreDataPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreDataPlaneName'", id.PacketCoreDataPlaneName, "packetCoreDataPlaneValue") + } +} + +func TestFormatPacketCoreDataPlaneID(t *testing.T) { + actual := NewPacketCoreDataPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue", "packetCoreDataPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreDataPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreDataPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue", + Expected: &PacketCoreDataPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + PacketCoreDataPlaneName: "packetCoreDataPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreDataPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.PacketCoreDataPlaneName != v.Expected.PacketCoreDataPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreDataPlaneName", v.Expected.PacketCoreDataPlaneName, actual.PacketCoreDataPlaneName) + } + + } +} + +func TestParsePacketCoreDataPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreDataPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue", + Expected: &PacketCoreDataPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + PacketCoreDataPlaneName: "packetCoreDataPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/packetCoreDataPlanes/packetCoreDataPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS/pAcKeTcOrEdAtApLaNeVaLuE", + Expected: &PacketCoreDataPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + PacketCoreDataPlaneName: "pAcKeTcOrEdAtApLaNeVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/pAcKeTcOrEdAtApLaNeS/pAcKeTcOrEdAtApLaNeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreDataPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + if actual.PacketCoreDataPlaneName != v.Expected.PacketCoreDataPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreDataPlaneName", v.Expected.PacketCoreDataPlaneName, actual.PacketCoreDataPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreDataPlaneId(t *testing.T) { + segments := PacketCoreDataPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreDataPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_createorupdate.go new file mode 100644 index 00000000000..5e31e974b6a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_createorupdate.go @@ -0,0 +1,75 @@ +package packetcoredataplane + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PacketCoreDataPlane +} + +// CreateOrUpdate ... +func (c PacketCoreDataPlaneClient) CreateOrUpdate(ctx context.Context, id PacketCoreDataPlaneId, input PacketCoreDataPlane) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PacketCoreDataPlaneClient) CreateOrUpdateThenPoll(ctx context.Context, id PacketCoreDataPlaneId, input PacketCoreDataPlane) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_delete.go new file mode 100644 index 00000000000..f54ab4de60b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_delete.go @@ -0,0 +1,71 @@ +package packetcoredataplane + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PacketCoreDataPlaneClient) Delete(ctx context.Context, id PacketCoreDataPlaneId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PacketCoreDataPlaneClient) DeleteThenPoll(ctx context.Context, id PacketCoreDataPlaneId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_get.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_get.go new file mode 100644 index 00000000000..6557c7e767d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_get.go @@ -0,0 +1,54 @@ +package packetcoredataplane + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PacketCoreDataPlane +} + +// Get ... +func (c PacketCoreDataPlaneClient) Get(ctx context.Context, id PacketCoreDataPlaneId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PacketCoreDataPlane + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_updatetags.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_updatetags.go new file mode 100644 index 00000000000..0f4fe0d633b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/method_updatetags.go @@ -0,0 +1,58 @@ +package packetcoredataplane + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PacketCoreDataPlane +} + +// UpdateTags ... +func (c PacketCoreDataPlaneClient) UpdateTags(ctx context.Context, id PacketCoreDataPlaneId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PacketCoreDataPlane + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_interfaceproperties.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_interfaceproperties.go new file mode 100644 index 00000000000..851eb83f65f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_interfaceproperties.go @@ -0,0 +1,14 @@ +package packetcoredataplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InterfaceProperties struct { + BfdIPv4Endpoints *[]string `json:"bfdIpv4Endpoints,omitempty"` + IPv4Address *string `json:"ipv4Address,omitempty"` + IPv4AddressList *[]string `json:"ipv4AddressList,omitempty"` + IPv4Gateway *string `json:"ipv4Gateway,omitempty"` + IPv4Subnet *string `json:"ipv4Subnet,omitempty"` + Name *string `json:"name,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_packetcoredataplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_packetcoredataplane.go new file mode 100644 index 00000000000..f2c24de019c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_packetcoredataplane.go @@ -0,0 +1,18 @@ +package packetcoredataplane + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreDataPlane struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties PacketCoreDataPlanePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_packetcoredataplanepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_packetcoredataplanepropertiesformat.go new file mode 100644 index 00000000000..6af43216a0a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_packetcoredataplanepropertiesformat.go @@ -0,0 +1,10 @@ +package packetcoredataplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreDataPlanePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + UserPlaneAccessInterface InterfaceProperties `json:"userPlaneAccessInterface"` + UserPlaneAccessVirtualIPv4Addresses *[]string `json:"userPlaneAccessVirtualIpv4Addresses,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_tagsobject.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_tagsobject.go new file mode 100644 index 00000000000..585ed682cb7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/model_tagsobject.go @@ -0,0 +1,8 @@ +package packetcoredataplane + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/version.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/version.go new file mode 100644 index 00000000000..21fd55e9eff --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplane/version.go @@ -0,0 +1,12 @@ +package packetcoredataplane + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/packetcoredataplane/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/README.md b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/README.md new file mode 100644 index 00000000000..e10eab6b151 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes` Documentation + +The `packetcoredataplanes` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes" +``` + + +### Client Initialization + +```go +client := packetcoredataplanes.NewPacketCoreDataPlanesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCoreDataPlanesClient.ListByPacketCoreControlPlane` + +```go +ctx := context.TODO() +id := packetcoredataplanes.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +// alternatively `client.ListByPacketCoreControlPlane(ctx, id)` can be used to do batched pagination +items, err := client.ListByPacketCoreControlPlaneComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/client.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/client.go new file mode 100644 index 00000000000..94e7e7d1d1b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/client.go @@ -0,0 +1,26 @@ +package packetcoredataplanes + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreDataPlanesClient struct { + Client *resourcemanager.Client +} + +func NewPacketCoreDataPlanesClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCoreDataPlanesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "packetcoredataplanes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCoreDataPlanesClient: %+v", err) + } + + return &PacketCoreDataPlanesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/constants.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/constants.go new file mode 100644 index 00000000000..fe479f19992 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/constants.go @@ -0,0 +1,66 @@ +package packetcoredataplanes + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/id_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/id_packetcorecontrolplane.go new file mode 100644 index 00000000000..5d027d57473 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/id_packetcorecontrolplane.go @@ -0,0 +1,130 @@ +package packetcoredataplanes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +// PacketCoreControlPlaneId is a struct representing the Resource ID for a Packet Core Control Plane +type PacketCoreControlPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string +} + +// NewPacketCoreControlPlaneID returns a new PacketCoreControlPlaneId struct +func NewPacketCoreControlPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string) PacketCoreControlPlaneId { + return PacketCoreControlPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + } +} + +// ParsePacketCoreControlPlaneID parses 'input' into a PacketCoreControlPlaneId +func ParsePacketCoreControlPlaneID(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneIDInsensitively(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneID checks that 'input' can be parsed as a Packet Core Control Plane ID +func ValidatePacketCoreControlPlaneID(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 := ParsePacketCoreControlPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + } + return fmt.Sprintf("Packet Core Control Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/id_packetcorecontrolplane_test.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/id_packetcorecontrolplane_test.go new file mode 100644 index 00000000000..ad5537a4442 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/id_packetcorecontrolplane_test.go @@ -0,0 +1,282 @@ +package packetcoredataplanes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +func TestNewPacketCoreControlPlaneID(t *testing.T) { + id := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } +} + +func TestFormatPacketCoreControlPlaneID(t *testing.T) { + actual := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestParsePacketCoreControlPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneId(t *testing.T) { + segments := PacketCoreControlPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/method_listbypacketcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/method_listbypacketcorecontrolplane.go new file mode 100644 index 00000000000..79d827a80ef --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/method_listbypacketcorecontrolplane.go @@ -0,0 +1,91 @@ +package packetcoredataplanes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByPacketCoreControlPlaneOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PacketCoreDataPlane +} + +type ListByPacketCoreControlPlaneCompleteResult struct { + LatestHttpResponse *http.Response + Items []PacketCoreDataPlane +} + +// ListByPacketCoreControlPlane ... +func (c PacketCoreDataPlanesClient) ListByPacketCoreControlPlane(ctx context.Context, id PacketCoreControlPlaneId) (result ListByPacketCoreControlPlaneOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/packetCoreDataPlanes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PacketCoreDataPlane `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByPacketCoreControlPlaneComplete retrieves all the results into a single object +func (c PacketCoreDataPlanesClient) ListByPacketCoreControlPlaneComplete(ctx context.Context, id PacketCoreControlPlaneId) (ListByPacketCoreControlPlaneCompleteResult, error) { + return c.ListByPacketCoreControlPlaneCompleteMatchingPredicate(ctx, id, PacketCoreDataPlaneOperationPredicate{}) +} + +// ListByPacketCoreControlPlaneCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PacketCoreDataPlanesClient) ListByPacketCoreControlPlaneCompleteMatchingPredicate(ctx context.Context, id PacketCoreControlPlaneId, predicate PacketCoreDataPlaneOperationPredicate) (result ListByPacketCoreControlPlaneCompleteResult, err error) { + items := make([]PacketCoreDataPlane, 0) + + resp, err := c.ListByPacketCoreControlPlane(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByPacketCoreControlPlaneCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_interfaceproperties.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_interfaceproperties.go new file mode 100644 index 00000000000..af38b25d491 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_interfaceproperties.go @@ -0,0 +1,14 @@ +package packetcoredataplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InterfaceProperties struct { + BfdIPv4Endpoints *[]string `json:"bfdIpv4Endpoints,omitempty"` + IPv4Address *string `json:"ipv4Address,omitempty"` + IPv4AddressList *[]string `json:"ipv4AddressList,omitempty"` + IPv4Gateway *string `json:"ipv4Gateway,omitempty"` + IPv4Subnet *string `json:"ipv4Subnet,omitempty"` + Name *string `json:"name,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_packetcoredataplane.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_packetcoredataplane.go new file mode 100644 index 00000000000..83fa8c85742 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_packetcoredataplane.go @@ -0,0 +1,18 @@ +package packetcoredataplanes + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreDataPlane struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties PacketCoreDataPlanePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_packetcoredataplanepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_packetcoredataplanepropertiesformat.go new file mode 100644 index 00000000000..f2434179556 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/model_packetcoredataplanepropertiesformat.go @@ -0,0 +1,10 @@ +package packetcoredataplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreDataPlanePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + UserPlaneAccessInterface InterfaceProperties `json:"userPlaneAccessInterface"` + UserPlaneAccessVirtualIPv4Addresses *[]string `json:"userPlaneAccessVirtualIpv4Addresses,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/predicates.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/predicates.go new file mode 100644 index 00000000000..f14d328d091 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/predicates.go @@ -0,0 +1,32 @@ +package packetcoredataplanes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreDataPlaneOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p PacketCoreDataPlaneOperationPredicate) Matches(input PacketCoreDataPlane) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/version.go b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/version.go new file mode 100644 index 00000000000..d49977d9341 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/packetcoredataplanes/version.go @@ -0,0 +1,12 @@ +package packetcoredataplanes + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/packetcoredataplanes/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/README.md b/resource-manager/mobilenetwork/2024-04-01/routinginfo/README.md new file mode 100644 index 00000000000..4388599cf1a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/routinginfo` Documentation + +The `routinginfo` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/routinginfo" +``` + + +### Client Initialization + +```go +client := routinginfo.NewRoutingInfoClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RoutingInfoClient.Get` + +```go +ctx := context.TODO() +id := routinginfo.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RoutingInfoClient.List` + +```go +ctx := context.TODO() +id := routinginfo.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/client.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/client.go new file mode 100644 index 00000000000..c4b4a2c705f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/client.go @@ -0,0 +1,26 @@ +package routinginfo + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingInfoClient struct { + Client *resourcemanager.Client +} + +func NewRoutingInfoClientWithBaseURI(sdkApi sdkEnv.Api) (*RoutingInfoClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "routinginfo", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RoutingInfoClient: %+v", err) + } + + return &RoutingInfoClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/id_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/id_packetcorecontrolplane.go new file mode 100644 index 00000000000..92df00c4f17 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/id_packetcorecontrolplane.go @@ -0,0 +1,130 @@ +package routinginfo + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +// PacketCoreControlPlaneId is a struct representing the Resource ID for a Packet Core Control Plane +type PacketCoreControlPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string +} + +// NewPacketCoreControlPlaneID returns a new PacketCoreControlPlaneId struct +func NewPacketCoreControlPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string) PacketCoreControlPlaneId { + return PacketCoreControlPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + } +} + +// ParsePacketCoreControlPlaneID parses 'input' into a PacketCoreControlPlaneId +func ParsePacketCoreControlPlaneID(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneIDInsensitively(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneID checks that 'input' can be parsed as a Packet Core Control Plane ID +func ValidatePacketCoreControlPlaneID(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 := ParsePacketCoreControlPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + } + return fmt.Sprintf("Packet Core Control Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/id_packetcorecontrolplane_test.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/id_packetcorecontrolplane_test.go new file mode 100644 index 00000000000..635c9ee36c4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/id_packetcorecontrolplane_test.go @@ -0,0 +1,282 @@ +package routinginfo + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +func TestNewPacketCoreControlPlaneID(t *testing.T) { + id := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } +} + +func TestFormatPacketCoreControlPlaneID(t *testing.T) { + actual := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestParsePacketCoreControlPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneId(t *testing.T) { + segments := PacketCoreControlPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/method_get.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/method_get.go new file mode 100644 index 00000000000..75927eb370d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/method_get.go @@ -0,0 +1,55 @@ +package routinginfo + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RoutingInfoModel +} + +// Get ... +func (c RoutingInfoClient) Get(ctx context.Context, id PacketCoreControlPlaneId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/routingInfo/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RoutingInfoModel + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/method_list.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/method_list.go new file mode 100644 index 00000000000..fdb45133a7d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/method_list.go @@ -0,0 +1,91 @@ +package routinginfo + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RoutingInfoModel +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RoutingInfoModel +} + +// List ... +func (c RoutingInfoClient) List(ctx context.Context, id PacketCoreControlPlaneId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/routingInfo", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RoutingInfoModel `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c RoutingInfoClient) ListComplete(ctx context.Context, id PacketCoreControlPlaneId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RoutingInfoModelOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RoutingInfoClient) ListCompleteMatchingPredicate(ctx context.Context, id PacketCoreControlPlaneId, predicate RoutingInfoModelOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RoutingInfoModel, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_attacheddatanetworkresourceid.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_attacheddatanetworkresourceid.go new file mode 100644 index 00000000000..3c91a03a215 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_attacheddatanetworkresourceid.go @@ -0,0 +1,8 @@ +package routinginfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetworkResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_ipv4route.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_ipv4route.go new file mode 100644 index 00000000000..423805fc80a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_ipv4route.go @@ -0,0 +1,9 @@ +package routinginfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv4Route struct { + Destination *string `json:"destination,omitempty"` + NextHops *[]IPv4RouteNextHop `json:"nextHops,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_ipv4routenexthop.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_ipv4routenexthop.go new file mode 100644 index 00000000000..28e2595f00f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_ipv4routenexthop.go @@ -0,0 +1,9 @@ +package routinginfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv4RouteNextHop struct { + Address *string `json:"address,omitempty"` + Priority *int64 `json:"priority,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_routinginfomodel.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_routinginfomodel.go new file mode 100644 index 00000000000..9c59ee27073 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_routinginfomodel.go @@ -0,0 +1,16 @@ +package routinginfo + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingInfoModel struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties RoutingInfoPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_routinginfopropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_routinginfopropertiesformat.go new file mode 100644 index 00000000000..418e0e1fa0a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_routinginfopropertiesformat.go @@ -0,0 +1,10 @@ +package routinginfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingInfoPropertiesFormat struct { + ControlPlaneAccessRoutes *[]IPv4Route `json:"controlPlaneAccessRoutes,omitempty"` + UserPlaneAccessRoutes *[]IPv4Route `json:"userPlaneAccessRoutes,omitempty"` + UserPlaneDataRoutes *[]UserPlaneDataRoutesUserPlaneDataRoutesInlined `json:"userPlaneDataRoutes,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_userplanedataroutesuserplanedataroutesinlined.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_userplanedataroutesuserplanedataroutesinlined.go new file mode 100644 index 00000000000..6785654ba6c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/model_userplanedataroutesuserplanedataroutesinlined.go @@ -0,0 +1,9 @@ +package routinginfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserPlaneDataRoutesUserPlaneDataRoutesInlined struct { + AttachedDataNetwork *AttachedDataNetworkResourceId `json:"attachedDataNetwork,omitempty"` + Routes *[]IPv4Route `json:"routes,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/predicates.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/predicates.go new file mode 100644 index 00000000000..63aea252995 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/predicates.go @@ -0,0 +1,27 @@ +package routinginfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingInfoModelOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RoutingInfoModelOperationPredicate) Matches(input RoutingInfoModel) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/routinginfo/version.go b/resource-manager/mobilenetwork/2024-04-01/routinginfo/version.go new file mode 100644 index 00000000000..42ef32f4aa1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/routinginfo/version.go @@ -0,0 +1,12 @@ +package routinginfo + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/routinginfo/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/README.md b/resource-manager/mobilenetwork/2024-04-01/service/README.md new file mode 100644 index 00000000000..7256e60924e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/service` Documentation + +The `service` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/service" +``` + + +### Client Initialization + +```go +client := service.NewServiceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServiceClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue") + +payload := service.Service{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceClient.Delete` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceClient.Get` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServiceClient.UpdateTags` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue") + +payload := service.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/service/client.go b/resource-manager/mobilenetwork/2024-04-01/service/client.go new file mode 100644 index 00000000000..d0e66ae6f3f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/client.go @@ -0,0 +1,26 @@ +package service + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceClient struct { + Client *resourcemanager.Client +} + +func NewServiceClientWithBaseURI(sdkApi sdkEnv.Api) (*ServiceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "service", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServiceClient: %+v", err) + } + + return &ServiceClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/constants.go b/resource-manager/mobilenetwork/2024-04-01/service/constants.go new file mode 100644 index 00000000000..f4431117472 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/constants.go @@ -0,0 +1,233 @@ +package service + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PreemptionCapability string + +const ( + PreemptionCapabilityMayPreempt PreemptionCapability = "MayPreempt" + PreemptionCapabilityNotPreempt PreemptionCapability = "NotPreempt" +) + +func PossibleValuesForPreemptionCapability() []string { + return []string{ + string(PreemptionCapabilityMayPreempt), + string(PreemptionCapabilityNotPreempt), + } +} + +func (s *PreemptionCapability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreemptionCapability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreemptionCapability(input string) (*PreemptionCapability, error) { + vals := map[string]PreemptionCapability{ + "maypreempt": PreemptionCapabilityMayPreempt, + "notpreempt": PreemptionCapabilityNotPreempt, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionCapability(input) + return &out, nil +} + +type PreemptionVulnerability string + +const ( + PreemptionVulnerabilityNotPreemptable PreemptionVulnerability = "NotPreemptable" + PreemptionVulnerabilityPreemptable PreemptionVulnerability = "Preemptable" +) + +func PossibleValuesForPreemptionVulnerability() []string { + return []string{ + string(PreemptionVulnerabilityNotPreemptable), + string(PreemptionVulnerabilityPreemptable), + } +} + +func (s *PreemptionVulnerability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreemptionVulnerability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreemptionVulnerability(input string) (*PreemptionVulnerability, error) { + vals := map[string]PreemptionVulnerability{ + "notpreemptable": PreemptionVulnerabilityNotPreemptable, + "preemptable": PreemptionVulnerabilityPreemptable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionVulnerability(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + 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 SdfDirection string + +const ( + SdfDirectionBidirectional SdfDirection = "Bidirectional" + SdfDirectionDownlink SdfDirection = "Downlink" + SdfDirectionUplink SdfDirection = "Uplink" +) + +func PossibleValuesForSdfDirection() []string { + return []string{ + string(SdfDirectionBidirectional), + string(SdfDirectionDownlink), + string(SdfDirectionUplink), + } +} + +func (s *SdfDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSdfDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSdfDirection(input string) (*SdfDirection, error) { + vals := map[string]SdfDirection{ + "bidirectional": SdfDirectionBidirectional, + "downlink": SdfDirectionDownlink, + "uplink": SdfDirectionUplink, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SdfDirection(input) + return &out, nil +} + +type TrafficControlPermission string + +const ( + TrafficControlPermissionBlocked TrafficControlPermission = "Blocked" + TrafficControlPermissionEnabled TrafficControlPermission = "Enabled" +) + +func PossibleValuesForTrafficControlPermission() []string { + return []string{ + string(TrafficControlPermissionBlocked), + string(TrafficControlPermissionEnabled), + } +} + +func (s *TrafficControlPermission) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTrafficControlPermission(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTrafficControlPermission(input string) (*TrafficControlPermission, error) { + vals := map[string]TrafficControlPermission{ + "blocked": TrafficControlPermissionBlocked, + "enabled": TrafficControlPermissionEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TrafficControlPermission(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/id_service.go b/resource-manager/mobilenetwork/2024-04-01/service/id_service.go new file mode 100644 index 00000000000..cd77155d153 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/id_service.go @@ -0,0 +1,139 @@ +package service + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServiceId{}) +} + +var _ resourceids.ResourceId = &ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string + ServiceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, mobileNetworkName string, serviceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + ServiceName: serviceName, + } +} + +// 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) + } + + id := ServiceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + 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) + } + + id := ServiceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + return 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.MobileNetwork/mobileNetworks/%s/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName, id.ServiceName) +} + +// 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("serviceName", "serviceValue"), + } +} + +// 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("Mobile Network Name: %q", id.MobileNetworkName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/id_service_test.go b/resource-manager/mobilenetwork/2024-04-01/service/id_service_test.go new file mode 100644 index 00000000000..d1e439e6a2b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/id_service_test.go @@ -0,0 +1,327 @@ +package service + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } + + if id.ServiceName != "serviceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceName'", id.ServiceName, "serviceValue") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/services/serviceValue" + 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/services/serviceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + ServiceName: "serviceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/services/serviceValue/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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/services/serviceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + ServiceName: "serviceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/services/serviceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sErViCeS/sErViCeVaLuE", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + ServiceName: "sErViCeVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sErViCeS/sErViCeVaLuE/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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +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/resource-manager/mobilenetwork/2024-04-01/service/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/service/method_createorupdate.go new file mode 100644 index 00000000000..0cb9d0c0a36 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/method_createorupdate.go @@ -0,0 +1,75 @@ +package service + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Service +} + +// CreateOrUpdate ... +func (c ServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input Service) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input Service) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/service/method_delete.go new file mode 100644 index 00000000000..92913350903 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/method_delete.go @@ -0,0 +1,71 @@ +package service + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ServiceClient) Delete(ctx context.Context, id ServiceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ServiceClient) DeleteThenPoll(ctx context.Context, id ServiceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/method_get.go b/resource-manager/mobilenetwork/2024-04-01/service/method_get.go new file mode 100644 index 00000000000..aa0841483b1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/method_get.go @@ -0,0 +1,54 @@ +package service + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Service +} + +// Get ... +func (c ServiceClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Service + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/method_updatetags.go b/resource-manager/mobilenetwork/2024-04-01/service/method_updatetags.go new file mode 100644 index 00000000000..919c2c845df --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/method_updatetags.go @@ -0,0 +1,58 @@ +package service + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Service +} + +// UpdateTags ... +func (c ServiceClient) UpdateTags(ctx context.Context, id ServiceId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Service + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/model_ambr.go b/resource-manager/mobilenetwork/2024-04-01/service/model_ambr.go new file mode 100644 index 00000000000..bb1e9df8076 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/model_ambr.go @@ -0,0 +1,9 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ambr struct { + Downlink string `json:"downlink"` + Uplink string `json:"uplink"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/model_pccruleconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/service/model_pccruleconfiguration.go new file mode 100644 index 00000000000..f15a71d7979 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/model_pccruleconfiguration.go @@ -0,0 +1,12 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PccRuleConfiguration struct { + RuleName string `json:"ruleName"` + RulePrecedence int64 `json:"rulePrecedence"` + RuleQosPolicy *PccRuleQosPolicy `json:"ruleQosPolicy,omitempty"` + ServiceDataFlowTemplates []ServiceDataFlowTemplate `json:"serviceDataFlowTemplates"` + TrafficControl *TrafficControlPermission `json:"trafficControl,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/model_pccruleqospolicy.go b/resource-manager/mobilenetwork/2024-04-01/service/model_pccruleqospolicy.go new file mode 100644 index 00000000000..e059d65446e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/model_pccruleqospolicy.go @@ -0,0 +1,13 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PccRuleQosPolicy struct { + AllocationAndRetentionPriorityLevel *int64 `json:"allocationAndRetentionPriorityLevel,omitempty"` + Fiveqi *int64 `json:"5qi,omitempty"` + GuaranteedBitRate *Ambr `json:"guaranteedBitRate,omitempty"` + MaximumBitRate Ambr `json:"maximumBitRate"` + PreemptionCapability *PreemptionCapability `json:"preemptionCapability,omitempty"` + PreemptionVulnerability *PreemptionVulnerability `json:"preemptionVulnerability,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/model_qospolicy.go b/resource-manager/mobilenetwork/2024-04-01/service/model_qospolicy.go new file mode 100644 index 00000000000..7dd7b833509 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/model_qospolicy.go @@ -0,0 +1,12 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QosPolicy struct { + AllocationAndRetentionPriorityLevel *int64 `json:"allocationAndRetentionPriorityLevel,omitempty"` + Fiveqi *int64 `json:"5qi,omitempty"` + MaximumBitRate Ambr `json:"maximumBitRate"` + PreemptionCapability *PreemptionCapability `json:"preemptionCapability,omitempty"` + PreemptionVulnerability *PreemptionVulnerability `json:"preemptionVulnerability,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/model_service.go b/resource-manager/mobilenetwork/2024-04-01/service/model_service.go new file mode 100644 index 00000000000..dca0696c002 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/model_service.go @@ -0,0 +1,18 @@ +package service + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Service struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties ServicePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/model_servicedataflowtemplate.go b/resource-manager/mobilenetwork/2024-04-01/service/model_servicedataflowtemplate.go new file mode 100644 index 00000000000..be719de3302 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/model_servicedataflowtemplate.go @@ -0,0 +1,12 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDataFlowTemplate struct { + Direction SdfDirection `json:"direction"` + Ports *[]string `json:"ports,omitempty"` + Protocol []string `json:"protocol"` + RemoteIPList []string `json:"remoteIpList"` + TemplateName string `json:"templateName"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/model_servicepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/service/model_servicepropertiesformat.go new file mode 100644 index 00000000000..aa890a8678d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/model_servicepropertiesformat.go @@ -0,0 +1,11 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServicePropertiesFormat struct { + PccRules []PccRuleConfiguration `json:"pccRules"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServicePrecedence int64 `json:"servicePrecedence"` + ServiceQosPolicy *QosPolicy `json:"serviceQosPolicy,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/model_tagsobject.go b/resource-manager/mobilenetwork/2024-04-01/service/model_tagsobject.go new file mode 100644 index 00000000000..b88d791c267 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/model_tagsobject.go @@ -0,0 +1,8 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/service/version.go b/resource-manager/mobilenetwork/2024-04-01/service/version.go new file mode 100644 index 00000000000..ccc96696bd5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/service/version.go @@ -0,0 +1,12 @@ +package service + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/service/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/README.md b/resource-manager/mobilenetwork/2024-04-01/services/README.md new file mode 100644 index 00000000000..71c87e6a610 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/services` Documentation + +The `services` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/services" +``` + + +### Client Initialization + +```go +client := services.NewServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServicesClient.ListByMobileNetwork` + +```go +ctx := context.TODO() +id := services.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +// alternatively `client.ListByMobileNetwork(ctx, id)` can be used to do batched pagination +items, err := client.ListByMobileNetworkComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/services/client.go b/resource-manager/mobilenetwork/2024-04-01/services/client.go new file mode 100644 index 00000000000..dc4a72c1ff4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/client.go @@ -0,0 +1,26 @@ +package services + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServicesClient struct { + Client *resourcemanager.Client +} + +func NewServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*ServicesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "services", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServicesClient: %+v", err) + } + + return &ServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/constants.go b/resource-manager/mobilenetwork/2024-04-01/services/constants.go new file mode 100644 index 00000000000..fe2eb1298fe --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/constants.go @@ -0,0 +1,233 @@ +package services + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PreemptionCapability string + +const ( + PreemptionCapabilityMayPreempt PreemptionCapability = "MayPreempt" + PreemptionCapabilityNotPreempt PreemptionCapability = "NotPreempt" +) + +func PossibleValuesForPreemptionCapability() []string { + return []string{ + string(PreemptionCapabilityMayPreempt), + string(PreemptionCapabilityNotPreempt), + } +} + +func (s *PreemptionCapability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreemptionCapability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreemptionCapability(input string) (*PreemptionCapability, error) { + vals := map[string]PreemptionCapability{ + "maypreempt": PreemptionCapabilityMayPreempt, + "notpreempt": PreemptionCapabilityNotPreempt, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionCapability(input) + return &out, nil +} + +type PreemptionVulnerability string + +const ( + PreemptionVulnerabilityNotPreemptable PreemptionVulnerability = "NotPreemptable" + PreemptionVulnerabilityPreemptable PreemptionVulnerability = "Preemptable" +) + +func PossibleValuesForPreemptionVulnerability() []string { + return []string{ + string(PreemptionVulnerabilityNotPreemptable), + string(PreemptionVulnerabilityPreemptable), + } +} + +func (s *PreemptionVulnerability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreemptionVulnerability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreemptionVulnerability(input string) (*PreemptionVulnerability, error) { + vals := map[string]PreemptionVulnerability{ + "notpreemptable": PreemptionVulnerabilityNotPreemptable, + "preemptable": PreemptionVulnerabilityPreemptable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionVulnerability(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + 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 SdfDirection string + +const ( + SdfDirectionBidirectional SdfDirection = "Bidirectional" + SdfDirectionDownlink SdfDirection = "Downlink" + SdfDirectionUplink SdfDirection = "Uplink" +) + +func PossibleValuesForSdfDirection() []string { + return []string{ + string(SdfDirectionBidirectional), + string(SdfDirectionDownlink), + string(SdfDirectionUplink), + } +} + +func (s *SdfDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSdfDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSdfDirection(input string) (*SdfDirection, error) { + vals := map[string]SdfDirection{ + "bidirectional": SdfDirectionBidirectional, + "downlink": SdfDirectionDownlink, + "uplink": SdfDirectionUplink, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SdfDirection(input) + return &out, nil +} + +type TrafficControlPermission string + +const ( + TrafficControlPermissionBlocked TrafficControlPermission = "Blocked" + TrafficControlPermissionEnabled TrafficControlPermission = "Enabled" +) + +func PossibleValuesForTrafficControlPermission() []string { + return []string{ + string(TrafficControlPermissionBlocked), + string(TrafficControlPermissionEnabled), + } +} + +func (s *TrafficControlPermission) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTrafficControlPermission(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTrafficControlPermission(input string) (*TrafficControlPermission, error) { + vals := map[string]TrafficControlPermission{ + "blocked": TrafficControlPermissionBlocked, + "enabled": TrafficControlPermissionEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TrafficControlPermission(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/id_mobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/services/id_mobilenetwork.go new file mode 100644 index 00000000000..aaa57c61499 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/id_mobilenetwork.go @@ -0,0 +1,130 @@ +package services + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MobileNetworkId{}) +} + +var _ resourceids.ResourceId = &MobileNetworkId{} + +// MobileNetworkId is a struct representing the Resource ID for a Mobile Network +type MobileNetworkId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string +} + +// NewMobileNetworkID returns a new MobileNetworkId struct +func NewMobileNetworkID(subscriptionId string, resourceGroupName string, mobileNetworkName string) MobileNetworkId { + return MobileNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + } +} + +// ParseMobileNetworkID parses 'input' into a MobileNetworkId +func ParseMobileNetworkID(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMobileNetworkIDInsensitively parses 'input' case-insensitively into a MobileNetworkId +// note: this method should only be used for API response data and not user input +func ParseMobileNetworkIDInsensitively(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MobileNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + return nil +} + +// ValidateMobileNetworkID checks that 'input' can be parsed as a Mobile Network ID +func ValidateMobileNetworkID(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 := ParseMobileNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mobile Network ID +func (id MobileNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mobile Network ID +func (id MobileNetworkId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + } +} + +// String returns a human-readable description of this Mobile Network ID +func (id MobileNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + } + return fmt.Sprintf("Mobile Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/id_mobilenetwork_test.go b/resource-manager/mobilenetwork/2024-04-01/services/id_mobilenetwork_test.go new file mode 100644 index 00000000000..b9b3117139a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/id_mobilenetwork_test.go @@ -0,0 +1,282 @@ +package services + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MobileNetworkId{} + +func TestNewMobileNetworkID(t *testing.T) { + id := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } +} + +func TestFormatMobileNetworkID(t *testing.T) { + actual := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMobileNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestParseMobileNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestSegmentsForMobileNetworkId(t *testing.T) { + segments := MobileNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MobileNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/method_listbymobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/services/method_listbymobilenetwork.go new file mode 100644 index 00000000000..3971350442f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/method_listbymobilenetwork.go @@ -0,0 +1,91 @@ +package services + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByMobileNetworkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Service +} + +type ListByMobileNetworkCompleteResult struct { + LatestHttpResponse *http.Response + Items []Service +} + +// ListByMobileNetwork ... +func (c ServicesClient) ListByMobileNetwork(ctx context.Context, id MobileNetworkId) (result ListByMobileNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/services", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Service `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByMobileNetworkComplete retrieves all the results into a single object +func (c ServicesClient) ListByMobileNetworkComplete(ctx context.Context, id MobileNetworkId) (ListByMobileNetworkCompleteResult, error) { + return c.ListByMobileNetworkCompleteMatchingPredicate(ctx, id, ServiceOperationPredicate{}) +} + +// ListByMobileNetworkCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServicesClient) ListByMobileNetworkCompleteMatchingPredicate(ctx context.Context, id MobileNetworkId, predicate ServiceOperationPredicate) (result ListByMobileNetworkCompleteResult, err error) { + items := make([]Service, 0) + + resp, err := c.ListByMobileNetwork(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByMobileNetworkCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/model_ambr.go b/resource-manager/mobilenetwork/2024-04-01/services/model_ambr.go new file mode 100644 index 00000000000..1889a76b2cc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/model_ambr.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ambr struct { + Downlink string `json:"downlink"` + Uplink string `json:"uplink"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/model_pccruleconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/services/model_pccruleconfiguration.go new file mode 100644 index 00000000000..0c392300b54 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/model_pccruleconfiguration.go @@ -0,0 +1,12 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PccRuleConfiguration struct { + RuleName string `json:"ruleName"` + RulePrecedence int64 `json:"rulePrecedence"` + RuleQosPolicy *PccRuleQosPolicy `json:"ruleQosPolicy,omitempty"` + ServiceDataFlowTemplates []ServiceDataFlowTemplate `json:"serviceDataFlowTemplates"` + TrafficControl *TrafficControlPermission `json:"trafficControl,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/model_pccruleqospolicy.go b/resource-manager/mobilenetwork/2024-04-01/services/model_pccruleqospolicy.go new file mode 100644 index 00000000000..4019222053c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/model_pccruleqospolicy.go @@ -0,0 +1,13 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PccRuleQosPolicy struct { + AllocationAndRetentionPriorityLevel *int64 `json:"allocationAndRetentionPriorityLevel,omitempty"` + Fiveqi *int64 `json:"5qi,omitempty"` + GuaranteedBitRate *Ambr `json:"guaranteedBitRate,omitempty"` + MaximumBitRate Ambr `json:"maximumBitRate"` + PreemptionCapability *PreemptionCapability `json:"preemptionCapability,omitempty"` + PreemptionVulnerability *PreemptionVulnerability `json:"preemptionVulnerability,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/model_qospolicy.go b/resource-manager/mobilenetwork/2024-04-01/services/model_qospolicy.go new file mode 100644 index 00000000000..ad0ab19f61a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/model_qospolicy.go @@ -0,0 +1,12 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QosPolicy struct { + AllocationAndRetentionPriorityLevel *int64 `json:"allocationAndRetentionPriorityLevel,omitempty"` + Fiveqi *int64 `json:"5qi,omitempty"` + MaximumBitRate Ambr `json:"maximumBitRate"` + PreemptionCapability *PreemptionCapability `json:"preemptionCapability,omitempty"` + PreemptionVulnerability *PreemptionVulnerability `json:"preemptionVulnerability,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/model_service.go b/resource-manager/mobilenetwork/2024-04-01/services/model_service.go new file mode 100644 index 00000000000..c59ca6ab2ba --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/model_service.go @@ -0,0 +1,18 @@ +package services + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Service struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties ServicePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/model_servicedataflowtemplate.go b/resource-manager/mobilenetwork/2024-04-01/services/model_servicedataflowtemplate.go new file mode 100644 index 00000000000..46b19bdb148 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/model_servicedataflowtemplate.go @@ -0,0 +1,12 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDataFlowTemplate struct { + Direction SdfDirection `json:"direction"` + Ports *[]string `json:"ports,omitempty"` + Protocol []string `json:"protocol"` + RemoteIPList []string `json:"remoteIpList"` + TemplateName string `json:"templateName"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/model_servicepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/services/model_servicepropertiesformat.go new file mode 100644 index 00000000000..09855b5cfda --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/model_servicepropertiesformat.go @@ -0,0 +1,11 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServicePropertiesFormat struct { + PccRules []PccRuleConfiguration `json:"pccRules"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServicePrecedence int64 `json:"servicePrecedence"` + ServiceQosPolicy *QosPolicy `json:"serviceQosPolicy,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/predicates.go b/resource-manager/mobilenetwork/2024-04-01/services/predicates.go new file mode 100644 index 00000000000..ab4d1a7dcf6 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/predicates.go @@ -0,0 +1,32 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ServiceOperationPredicate) Matches(input Service) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/services/version.go b/resource-manager/mobilenetwork/2024-04-01/services/version.go new file mode 100644 index 00000000000..a4433d1c2c1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/services/version.go @@ -0,0 +1,12 @@ +package services + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/services/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/README.md b/resource-manager/mobilenetwork/2024-04-01/sim/README.md new file mode 100644 index 00000000000..4e02763f062 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/sim` Documentation + +The `sim` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/sim" +``` + + +### Client Initialization + +```go +client := sim.NewSIMClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SIMClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := sim.NewSimID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue", "simValue") + +payload := sim.Sim{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMClient.Delete` + +```go +ctx := context.TODO() +id := sim.NewSimID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue", "simValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMClient.Get` + +```go +ctx := context.TODO() +id := sim.NewSimID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue", "simValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/client.go b/resource-manager/mobilenetwork/2024-04-01/sim/client.go new file mode 100644 index 00000000000..8a43d650628 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/client.go @@ -0,0 +1,26 @@ +package sim + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SIMClient struct { + Client *resourcemanager.Client +} + +func NewSIMClientWithBaseURI(sdkApi sdkEnv.Api) (*SIMClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "sim", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SIMClient: %+v", err) + } + + return &SIMClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/constants.go b/resource-manager/mobilenetwork/2024-04-01/sim/constants.go new file mode 100644 index 00000000000..ba9f2fa11ff --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/constants.go @@ -0,0 +1,163 @@ +package sim + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + 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 SimState string + +const ( + SimStateDisabled SimState = "Disabled" + SimStateEnabled SimState = "Enabled" + SimStateInvalid SimState = "Invalid" +) + +func PossibleValuesForSimState() []string { + return []string{ + string(SimStateDisabled), + string(SimStateEnabled), + string(SimStateInvalid), + } +} + +func (s *SimState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSimState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSimState(input string) (*SimState, error) { + vals := map[string]SimState{ + "disabled": SimStateDisabled, + "enabled": SimStateEnabled, + "invalid": SimStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SimState(input) + return &out, nil +} + +type SiteProvisioningState string + +const ( + SiteProvisioningStateAdding SiteProvisioningState = "Adding" + SiteProvisioningStateDeleting SiteProvisioningState = "Deleting" + SiteProvisioningStateFailed SiteProvisioningState = "Failed" + SiteProvisioningStateNotApplicable SiteProvisioningState = "NotApplicable" + SiteProvisioningStateProvisioned SiteProvisioningState = "Provisioned" + SiteProvisioningStateUpdating SiteProvisioningState = "Updating" +) + +func PossibleValuesForSiteProvisioningState() []string { + return []string{ + string(SiteProvisioningStateAdding), + string(SiteProvisioningStateDeleting), + string(SiteProvisioningStateFailed), + string(SiteProvisioningStateNotApplicable), + string(SiteProvisioningStateProvisioned), + string(SiteProvisioningStateUpdating), + } +} + +func (s *SiteProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteProvisioningState(input string) (*SiteProvisioningState, error) { + vals := map[string]SiteProvisioningState{ + "adding": SiteProvisioningStateAdding, + "deleting": SiteProvisioningStateDeleting, + "failed": SiteProvisioningStateFailed, + "notapplicable": SiteProvisioningStateNotApplicable, + "provisioned": SiteProvisioningStateProvisioned, + "updating": SiteProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/id_sim.go b/resource-manager/mobilenetwork/2024-04-01/sim/id_sim.go new file mode 100644 index 00000000000..4fb50ab65ce --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/id_sim.go @@ -0,0 +1,139 @@ +package sim + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SimId{}) +} + +var _ resourceids.ResourceId = &SimId{} + +// SimId is a struct representing the Resource ID for a Sim +type SimId struct { + SubscriptionId string + ResourceGroupName string + SimGroupName string + SimName string +} + +// NewSimID returns a new SimId struct +func NewSimID(subscriptionId string, resourceGroupName string, simGroupName string, simName string) SimId { + return SimId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SimGroupName: simGroupName, + SimName: simName, + } +} + +// ParseSimID parses 'input' into a SimId +func ParseSimID(input string) (*SimId, error) { + parser := resourceids.NewParserFromResourceIdType(&SimId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SimId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSimIDInsensitively parses 'input' case-insensitively into a SimId +// note: this method should only be used for API response data and not user input +func ParseSimIDInsensitively(input string) (*SimId, error) { + parser := resourceids.NewParserFromResourceIdType(&SimId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SimId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SimId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SimGroupName, ok = input.Parsed["simGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "simGroupName", input) + } + + if id.SimName, ok = input.Parsed["simName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "simName", input) + } + + return nil +} + +// ValidateSimID checks that 'input' can be parsed as a Sim ID +func ValidateSimID(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 := ParseSimID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sim ID +func (id SimId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/simGroups/%s/sims/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SimGroupName, id.SimName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sim ID +func (id SimId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticSimGroups", "simGroups", "simGroups"), + resourceids.UserSpecifiedSegment("simGroupName", "simGroupValue"), + resourceids.StaticSegment("staticSims", "sims", "sims"), + resourceids.UserSpecifiedSegment("simName", "simValue"), + } +} + +// String returns a human-readable description of this Sim ID +func (id SimId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sim Group Name: %q", id.SimGroupName), + fmt.Sprintf("Sim Name: %q", id.SimName), + } + return fmt.Sprintf("Sim (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/id_sim_test.go b/resource-manager/mobilenetwork/2024-04-01/sim/id_sim_test.go new file mode 100644 index 00000000000..5acff9a507b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/id_sim_test.go @@ -0,0 +1,327 @@ +package sim + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SimId{} + +func TestNewSimID(t *testing.T) { + id := NewSimID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue", "simValue") + + 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.SimGroupName != "simGroupValue" { + t.Fatalf("Expected %q but got %q for Segment 'SimGroupName'", id.SimGroupName, "simGroupValue") + } + + if id.SimName != "simValue" { + t.Fatalf("Expected %q but got %q for Segment 'SimName'", id.SimName, "simValue") + } +} + +func TestFormatSimID(t *testing.T) { + actual := NewSimID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue", "simValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/sims/simValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSimID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SimId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/sims", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/sims/simValue", + Expected: &SimId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SimGroupName: "simGroupValue", + SimName: "simValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/sims/simValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSimID(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.SimGroupName != v.Expected.SimGroupName { + t.Fatalf("Expected %q but got %q for SimGroupName", v.Expected.SimGroupName, actual.SimGroupName) + } + + if actual.SimName != v.Expected.SimName { + t.Fatalf("Expected %q but got %q for SimName", v.Expected.SimName, actual.SimName) + } + + } +} + +func TestParseSimIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SimId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/sImGrOuPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/sImGrOuPs/sImGrOuPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/sims", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/sImGrOuPs/sImGrOuPvAlUe/sImS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/sims/simValue", + Expected: &SimId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SimGroupName: "simGroupValue", + SimName: "simValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/sims/simValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/sImGrOuPs/sImGrOuPvAlUe/sImS/sImVaLuE", + Expected: &SimId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SimGroupName: "sImGrOuPvAlUe", + SimName: "sImVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/sImGrOuPs/sImGrOuPvAlUe/sImS/sImVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSimIDInsensitively(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.SimGroupName != v.Expected.SimGroupName { + t.Fatalf("Expected %q but got %q for SimGroupName", v.Expected.SimGroupName, actual.SimGroupName) + } + + if actual.SimName != v.Expected.SimName { + t.Fatalf("Expected %q but got %q for SimName", v.Expected.SimName, actual.SimName) + } + + } +} + +func TestSegmentsForSimId(t *testing.T) { + segments := SimId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SimId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/sim/method_createorupdate.go new file mode 100644 index 00000000000..27257cf18ef --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/method_createorupdate.go @@ -0,0 +1,75 @@ +package sim + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Sim +} + +// CreateOrUpdate ... +func (c SIMClient) CreateOrUpdate(ctx context.Context, id SimId, input Sim) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SIMClient) CreateOrUpdateThenPoll(ctx context.Context, id SimId, input Sim) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/sim/method_delete.go new file mode 100644 index 00000000000..a2fb2ef9fc4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/method_delete.go @@ -0,0 +1,71 @@ +package sim + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SIMClient) Delete(ctx context.Context, id SimId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SIMClient) DeleteThenPoll(ctx context.Context, id SimId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/method_get.go b/resource-manager/mobilenetwork/2024-04-01/sim/method_get.go new file mode 100644 index 00000000000..6b99fbc6db7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/method_get.go @@ -0,0 +1,54 @@ +package sim + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Sim +} + +// Get ... +func (c SIMClient) Get(ctx context.Context, id SimId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Sim + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/model_attacheddatanetworkresourceid.go b/resource-manager/mobilenetwork/2024-04-01/sim/model_attacheddatanetworkresourceid.go new file mode 100644 index 00000000000..c79ccd9ca92 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/model_attacheddatanetworkresourceid.go @@ -0,0 +1,8 @@ +package sim + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetworkResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/model_sim.go b/resource-manager/mobilenetwork/2024-04-01/sim/model_sim.go new file mode 100644 index 00000000000..fffaa565b7c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/model_sim.go @@ -0,0 +1,16 @@ +package sim + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sim struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties SimPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/model_simpolicyresourceid.go b/resource-manager/mobilenetwork/2024-04-01/sim/model_simpolicyresourceid.go new file mode 100644 index 00000000000..a70633e129c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/model_simpolicyresourceid.go @@ -0,0 +1,8 @@ +package sim + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPolicyResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/model_simpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/sim/model_simpropertiesformat.go new file mode 100644 index 00000000000..b6b3704e57a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/model_simpropertiesformat.go @@ -0,0 +1,19 @@ +package sim + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPropertiesFormat struct { + AuthenticationKey *string `json:"authenticationKey,omitempty"` + DeviceType *string `json:"deviceType,omitempty"` + IntegratedCircuitCardIdentifier *string `json:"integratedCircuitCardIdentifier,omitempty"` + InternationalMobileSubscriberIdentity string `json:"internationalMobileSubscriberIdentity"` + OperatorKeyCode *string `json:"operatorKeyCode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SimPolicy *SimPolicyResourceId `json:"simPolicy,omitempty"` + SimState *SimState `json:"simState,omitempty"` + SiteProvisioningState *map[string]SiteProvisioningState `json:"siteProvisioningState,omitempty"` + StaticIPConfiguration *[]SimStaticIPProperties `json:"staticIpConfiguration,omitempty"` + VendorKeyFingerprint *string `json:"vendorKeyFingerprint,omitempty"` + VendorName *string `json:"vendorName,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/model_simstaticipproperties.go b/resource-manager/mobilenetwork/2024-04-01/sim/model_simstaticipproperties.go new file mode 100644 index 00000000000..3160996d848 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/model_simstaticipproperties.go @@ -0,0 +1,10 @@ +package sim + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimStaticIPProperties struct { + AttachedDataNetwork *AttachedDataNetworkResourceId `json:"attachedDataNetwork,omitempty"` + Slice *SliceResourceId `json:"slice,omitempty"` + StaticIP *SimStaticIPPropertiesStaticIP `json:"staticIp,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/model_simstaticippropertiesstaticip.go b/resource-manager/mobilenetwork/2024-04-01/sim/model_simstaticippropertiesstaticip.go new file mode 100644 index 00000000000..42fd46649a1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/model_simstaticippropertiesstaticip.go @@ -0,0 +1,8 @@ +package sim + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimStaticIPPropertiesStaticIP struct { + IPv4Address *string `json:"ipv4Address,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/model_sliceresourceid.go b/resource-manager/mobilenetwork/2024-04-01/sim/model_sliceresourceid.go new file mode 100644 index 00000000000..5c9463dad7c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/model_sliceresourceid.go @@ -0,0 +1,8 @@ +package sim + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SliceResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sim/version.go b/resource-manager/mobilenetwork/2024-04-01/sim/version.go new file mode 100644 index 00000000000..6b6b3562871 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sim/version.go @@ -0,0 +1,12 @@ +package sim + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/sim/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/README.md b/resource-manager/mobilenetwork/2024-04-01/simgroup/README.md new file mode 100644 index 00000000000..9bafbbd09d6 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simgroup` Documentation + +The `simgroup` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simgroup" +``` + + +### Client Initialization + +```go +client := simgroup.NewSIMGroupClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SIMGroupClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := simgroup.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +payload := simgroup.SimGroup{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMGroupClient.Delete` + +```go +ctx := context.TODO() +id := simgroup.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMGroupClient.Get` + +```go +ctx := context.TODO() +id := simgroup.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SIMGroupClient.UpdateTags` + +```go +ctx := context.TODO() +id := simgroup.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +payload := simgroup.IdentityAndTagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/client.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/client.go new file mode 100644 index 00000000000..246564366ab --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/client.go @@ -0,0 +1,26 @@ +package simgroup + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SIMGroupClient struct { + Client *resourcemanager.Client +} + +func NewSIMGroupClientWithBaseURI(sdkApi sdkEnv.Api) (*SIMGroupClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "simgroup", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SIMGroupClient: %+v", err) + } + + return &SIMGroupClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/constants.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/constants.go new file mode 100644 index 00000000000..e0b20707df4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/constants.go @@ -0,0 +1,66 @@ +package simgroup + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/id_simgroup.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/id_simgroup.go new file mode 100644 index 00000000000..9da4886e888 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/id_simgroup.go @@ -0,0 +1,130 @@ +package simgroup + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SimGroupId{}) +} + +var _ resourceids.ResourceId = &SimGroupId{} + +// SimGroupId is a struct representing the Resource ID for a Sim Group +type SimGroupId struct { + SubscriptionId string + ResourceGroupName string + SimGroupName string +} + +// NewSimGroupID returns a new SimGroupId struct +func NewSimGroupID(subscriptionId string, resourceGroupName string, simGroupName string) SimGroupId { + return SimGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SimGroupName: simGroupName, + } +} + +// ParseSimGroupID parses 'input' into a SimGroupId +func ParseSimGroupID(input string) (*SimGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SimGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SimGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSimGroupIDInsensitively parses 'input' case-insensitively into a SimGroupId +// note: this method should only be used for API response data and not user input +func ParseSimGroupIDInsensitively(input string) (*SimGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SimGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SimGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SimGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SimGroupName, ok = input.Parsed["simGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "simGroupName", input) + } + + return nil +} + +// ValidateSimGroupID checks that 'input' can be parsed as a Sim Group ID +func ValidateSimGroupID(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 := ParseSimGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sim Group ID +func (id SimGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/simGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SimGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sim Group ID +func (id SimGroupId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticSimGroups", "simGroups", "simGroups"), + resourceids.UserSpecifiedSegment("simGroupName", "simGroupValue"), + } +} + +// String returns a human-readable description of this Sim Group ID +func (id SimGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sim Group Name: %q", id.SimGroupName), + } + return fmt.Sprintf("Sim Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/id_simgroup_test.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/id_simgroup_test.go new file mode 100644 index 00000000000..af48c5acd05 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/id_simgroup_test.go @@ -0,0 +1,282 @@ +package simgroup + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SimGroupId{} + +func TestNewSimGroupID(t *testing.T) { + id := NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + + 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.SimGroupName != "simGroupValue" { + t.Fatalf("Expected %q but got %q for Segment 'SimGroupName'", id.SimGroupName, "simGroupValue") + } +} + +func TestFormatSimGroupID(t *testing.T) { + actual := NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSimGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SimGroupId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue", + Expected: &SimGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SimGroupName: "simGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSimGroupID(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.SimGroupName != v.Expected.SimGroupName { + t.Fatalf("Expected %q but got %q for SimGroupName", v.Expected.SimGroupName, actual.SimGroupName) + } + + } +} + +func TestParseSimGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SimGroupId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/sImGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue", + Expected: &SimGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SimGroupName: "simGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/sImGrOuPs/sImGrOuPvAlUe", + Expected: &SimGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SimGroupName: "sImGrOuPvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/sImGrOuPs/sImGrOuPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSimGroupIDInsensitively(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.SimGroupName != v.Expected.SimGroupName { + t.Fatalf("Expected %q but got %q for SimGroupName", v.Expected.SimGroupName, actual.SimGroupName) + } + + } +} + +func TestSegmentsForSimGroupId(t *testing.T) { + segments := SimGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SimGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/method_createorupdate.go new file mode 100644 index 00000000000..68a38b3f6a0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/method_createorupdate.go @@ -0,0 +1,75 @@ +package simgroup + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SimGroup +} + +// CreateOrUpdate ... +func (c SIMGroupClient) CreateOrUpdate(ctx context.Context, id SimGroupId, input SimGroup) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SIMGroupClient) CreateOrUpdateThenPoll(ctx context.Context, id SimGroupId, input SimGroup) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/method_delete.go new file mode 100644 index 00000000000..79e9d7ac1d0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/method_delete.go @@ -0,0 +1,71 @@ +package simgroup + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SIMGroupClient) Delete(ctx context.Context, id SimGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SIMGroupClient) DeleteThenPoll(ctx context.Context, id SimGroupId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/method_get.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/method_get.go new file mode 100644 index 00000000000..6ea6342dc94 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/method_get.go @@ -0,0 +1,54 @@ +package simgroup + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SimGroup +} + +// Get ... +func (c SIMGroupClient) Get(ctx context.Context, id SimGroupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SimGroup + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/method_updatetags.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/method_updatetags.go new file mode 100644 index 00000000000..3757c9fafb7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/method_updatetags.go @@ -0,0 +1,58 @@ +package simgroup + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SimGroup +} + +// UpdateTags ... +func (c SIMGroupClient) UpdateTags(ctx context.Context, id SimGroupId, input IdentityAndTagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SimGroup + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/model_identityandtagsobject.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_identityandtagsobject.go new file mode 100644 index 00000000000..3815a7de587 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_identityandtagsobject.go @@ -0,0 +1,13 @@ +package simgroup + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityAndTagsObject struct { + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/model_keyvaultkey.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_keyvaultkey.go new file mode 100644 index 00000000000..679efab87d3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_keyvaultkey.go @@ -0,0 +1,8 @@ +package simgroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultKey struct { + KeyUrl *string `json:"keyUrl,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/model_mobilenetworkresourceid.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_mobilenetworkresourceid.go new file mode 100644 index 00000000000..cc19f088ff2 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_mobilenetworkresourceid.go @@ -0,0 +1,8 @@ +package simgroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetworkResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/model_simgroup.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_simgroup.go new file mode 100644 index 00000000000..b9911f29199 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_simgroup.go @@ -0,0 +1,20 @@ +package simgroup + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimGroup struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties SimGroupPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/model_simgrouppropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_simgrouppropertiesformat.go new file mode 100644 index 00000000000..387aab0db0f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/model_simgrouppropertiesformat.go @@ -0,0 +1,10 @@ +package simgroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimGroupPropertiesFormat struct { + EncryptionKey *KeyVaultKey `json:"encryptionKey,omitempty"` + MobileNetwork *MobileNetworkResourceId `json:"mobileNetwork,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroup/version.go b/resource-manager/mobilenetwork/2024-04-01/simgroup/version.go new file mode 100644 index 00000000000..ef20bf93542 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroup/version.go @@ -0,0 +1,12 @@ +package simgroup + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/simgroup/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/README.md b/resource-manager/mobilenetwork/2024-04-01/simgroups/README.md new file mode 100644 index 00000000000..589bc36d26a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/README.md @@ -0,0 +1,55 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simgroups` Documentation + +The `simgroups` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simgroups" +``` + + +### Client Initialization + +```go +client := simgroups.NewSIMGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SIMGroupsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SIMGroupsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/client.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/client.go new file mode 100644 index 00000000000..3bbaf2d36ff --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/client.go @@ -0,0 +1,26 @@ +package simgroups + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SIMGroupsClient struct { + Client *resourcemanager.Client +} + +func NewSIMGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*SIMGroupsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "simgroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SIMGroupsClient: %+v", err) + } + + return &SIMGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/constants.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/constants.go new file mode 100644 index 00000000000..3d7ba8815a0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/constants.go @@ -0,0 +1,66 @@ +package simgroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/method_listbyresourcegroup.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/method_listbyresourcegroup.go new file mode 100644 index 00000000000..9bb84abff2e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package simgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SimGroup +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SimGroup +} + +// ListByResourceGroup ... +func (c SIMGroupsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.MobileNetwork/simGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SimGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c SIMGroupsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SimGroupOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SIMGroupsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SimGroupOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SimGroup, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/method_listbysubscription.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/method_listbysubscription.go new file mode 100644 index 00000000000..8e95c9ce327 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/method_listbysubscription.go @@ -0,0 +1,92 @@ +package simgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SimGroup +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SimGroup +} + +// ListBySubscription ... +func (c SIMGroupsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.MobileNetwork/simGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SimGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c SIMGroupsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SimGroupOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SIMGroupsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SimGroupOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]SimGroup, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/model_keyvaultkey.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/model_keyvaultkey.go new file mode 100644 index 00000000000..445fb38c548 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/model_keyvaultkey.go @@ -0,0 +1,8 @@ +package simgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultKey struct { + KeyUrl *string `json:"keyUrl,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/model_mobilenetworkresourceid.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/model_mobilenetworkresourceid.go new file mode 100644 index 00000000000..48b212d3e94 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/model_mobilenetworkresourceid.go @@ -0,0 +1,8 @@ +package simgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobileNetworkResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/model_simgroup.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/model_simgroup.go new file mode 100644 index 00000000000..c1a29cc70f2 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/model_simgroup.go @@ -0,0 +1,20 @@ +package simgroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimGroup struct { + Id *string `json:"id,omitempty"` + Identity *identity.UserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties SimGroupPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/model_simgrouppropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/model_simgrouppropertiesformat.go new file mode 100644 index 00000000000..ad96c6eea7b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/model_simgrouppropertiesformat.go @@ -0,0 +1,10 @@ +package simgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimGroupPropertiesFormat struct { + EncryptionKey *KeyVaultKey `json:"encryptionKey,omitempty"` + MobileNetwork *MobileNetworkResourceId `json:"mobileNetwork,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/predicates.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/predicates.go new file mode 100644 index 00000000000..8366b98bf49 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/predicates.go @@ -0,0 +1,32 @@ +package simgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimGroupOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SimGroupOperationPredicate) Matches(input SimGroup) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simgroups/version.go b/resource-manager/mobilenetwork/2024-04-01/simgroups/version.go new file mode 100644 index 00000000000..a5b3187adaa --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simgroups/version.go @@ -0,0 +1,12 @@ +package simgroups + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/simgroups/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/README.md b/resource-manager/mobilenetwork/2024-04-01/simpolicies/README.md new file mode 100644 index 00000000000..ab00e91bc8f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simpolicies` Documentation + +The `simpolicies` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simpolicies" +``` + + +### Client Initialization + +```go +client := simpolicies.NewSIMPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SIMPoliciesClient.ListByMobileNetwork` + +```go +ctx := context.TODO() +id := simpolicies.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +// alternatively `client.ListByMobileNetwork(ctx, id)` can be used to do batched pagination +items, err := client.ListByMobileNetworkComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/client.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/client.go new file mode 100644 index 00000000000..44d15eac3ad --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/client.go @@ -0,0 +1,26 @@ +package simpolicies + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SIMPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewSIMPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*SIMPoliciesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "simpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SIMPoliciesClient: %+v", err) + } + + return &SIMPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/constants.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/constants.go new file mode 100644 index 00000000000..f4a85ffa39b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/constants.go @@ -0,0 +1,242 @@ +package simpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PduSessionType string + +const ( + PduSessionTypeIPvFour PduSessionType = "IPv4" + PduSessionTypeIPvSix PduSessionType = "IPv6" +) + +func PossibleValuesForPduSessionType() []string { + return []string{ + string(PduSessionTypeIPvFour), + string(PduSessionTypeIPvSix), + } +} + +func (s *PduSessionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePduSessionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePduSessionType(input string) (*PduSessionType, error) { + vals := map[string]PduSessionType{ + "ipv4": PduSessionTypeIPvFour, + "ipv6": PduSessionTypeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PduSessionType(input) + return &out, nil +} + +type PreemptionCapability string + +const ( + PreemptionCapabilityMayPreempt PreemptionCapability = "MayPreempt" + PreemptionCapabilityNotPreempt PreemptionCapability = "NotPreempt" +) + +func PossibleValuesForPreemptionCapability() []string { + return []string{ + string(PreemptionCapabilityMayPreempt), + string(PreemptionCapabilityNotPreempt), + } +} + +func (s *PreemptionCapability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreemptionCapability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreemptionCapability(input string) (*PreemptionCapability, error) { + vals := map[string]PreemptionCapability{ + "maypreempt": PreemptionCapabilityMayPreempt, + "notpreempt": PreemptionCapabilityNotPreempt, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionCapability(input) + return &out, nil +} + +type PreemptionVulnerability string + +const ( + PreemptionVulnerabilityNotPreemptable PreemptionVulnerability = "NotPreemptable" + PreemptionVulnerabilityPreemptable PreemptionVulnerability = "Preemptable" +) + +func PossibleValuesForPreemptionVulnerability() []string { + return []string{ + string(PreemptionVulnerabilityNotPreemptable), + string(PreemptionVulnerabilityPreemptable), + } +} + +func (s *PreemptionVulnerability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreemptionVulnerability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreemptionVulnerability(input string) (*PreemptionVulnerability, error) { + vals := map[string]PreemptionVulnerability{ + "notpreemptable": PreemptionVulnerabilityNotPreemptable, + "preemptable": PreemptionVulnerabilityPreemptable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionVulnerability(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + 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 SiteProvisioningState string + +const ( + SiteProvisioningStateAdding SiteProvisioningState = "Adding" + SiteProvisioningStateDeleting SiteProvisioningState = "Deleting" + SiteProvisioningStateFailed SiteProvisioningState = "Failed" + SiteProvisioningStateNotApplicable SiteProvisioningState = "NotApplicable" + SiteProvisioningStateProvisioned SiteProvisioningState = "Provisioned" + SiteProvisioningStateUpdating SiteProvisioningState = "Updating" +) + +func PossibleValuesForSiteProvisioningState() []string { + return []string{ + string(SiteProvisioningStateAdding), + string(SiteProvisioningStateDeleting), + string(SiteProvisioningStateFailed), + string(SiteProvisioningStateNotApplicable), + string(SiteProvisioningStateProvisioned), + string(SiteProvisioningStateUpdating), + } +} + +func (s *SiteProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteProvisioningState(input string) (*SiteProvisioningState, error) { + vals := map[string]SiteProvisioningState{ + "adding": SiteProvisioningStateAdding, + "deleting": SiteProvisioningStateDeleting, + "failed": SiteProvisioningStateFailed, + "notapplicable": SiteProvisioningStateNotApplicable, + "provisioned": SiteProvisioningStateProvisioned, + "updating": SiteProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/id_mobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/id_mobilenetwork.go new file mode 100644 index 00000000000..9c9024dc846 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/id_mobilenetwork.go @@ -0,0 +1,130 @@ +package simpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MobileNetworkId{}) +} + +var _ resourceids.ResourceId = &MobileNetworkId{} + +// MobileNetworkId is a struct representing the Resource ID for a Mobile Network +type MobileNetworkId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string +} + +// NewMobileNetworkID returns a new MobileNetworkId struct +func NewMobileNetworkID(subscriptionId string, resourceGroupName string, mobileNetworkName string) MobileNetworkId { + return MobileNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + } +} + +// ParseMobileNetworkID parses 'input' into a MobileNetworkId +func ParseMobileNetworkID(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMobileNetworkIDInsensitively parses 'input' case-insensitively into a MobileNetworkId +// note: this method should only be used for API response data and not user input +func ParseMobileNetworkIDInsensitively(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MobileNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + return nil +} + +// ValidateMobileNetworkID checks that 'input' can be parsed as a Mobile Network ID +func ValidateMobileNetworkID(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 := ParseMobileNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mobile Network ID +func (id MobileNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mobile Network ID +func (id MobileNetworkId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + } +} + +// String returns a human-readable description of this Mobile Network ID +func (id MobileNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + } + return fmt.Sprintf("Mobile Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/id_mobilenetwork_test.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/id_mobilenetwork_test.go new file mode 100644 index 00000000000..b6353426a5c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/id_mobilenetwork_test.go @@ -0,0 +1,282 @@ +package simpolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MobileNetworkId{} + +func TestNewMobileNetworkID(t *testing.T) { + id := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } +} + +func TestFormatMobileNetworkID(t *testing.T) { + actual := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMobileNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestParseMobileNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestSegmentsForMobileNetworkId(t *testing.T) { + segments := MobileNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MobileNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/method_listbymobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/method_listbymobilenetwork.go new file mode 100644 index 00000000000..a7b2f04e28f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/method_listbymobilenetwork.go @@ -0,0 +1,91 @@ +package simpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByMobileNetworkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SimPolicy +} + +type ListByMobileNetworkCompleteResult struct { + LatestHttpResponse *http.Response + Items []SimPolicy +} + +// ListByMobileNetwork ... +func (c SIMPoliciesClient) ListByMobileNetwork(ctx context.Context, id MobileNetworkId) (result ListByMobileNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/simPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SimPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByMobileNetworkComplete retrieves all the results into a single object +func (c SIMPoliciesClient) ListByMobileNetworkComplete(ctx context.Context, id MobileNetworkId) (ListByMobileNetworkCompleteResult, error) { + return c.ListByMobileNetworkCompleteMatchingPredicate(ctx, id, SimPolicyOperationPredicate{}) +} + +// ListByMobileNetworkCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SIMPoliciesClient) ListByMobileNetworkCompleteMatchingPredicate(ctx context.Context, id MobileNetworkId, predicate SimPolicyOperationPredicate) (result ListByMobileNetworkCompleteResult, err error) { + items := make([]SimPolicy, 0) + + resp, err := c.ListByMobileNetwork(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByMobileNetworkCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_ambr.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_ambr.go new file mode 100644 index 00000000000..151edd08ec7 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_ambr.go @@ -0,0 +1,9 @@ +package simpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ambr struct { + Downlink string `json:"downlink"` + Uplink string `json:"uplink"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_datanetworkconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_datanetworkconfiguration.go new file mode 100644 index 00000000000..f5b213c16f9 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_datanetworkconfiguration.go @@ -0,0 +1,17 @@ +package simpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetworkConfiguration struct { + AdditionalAllowedSessionTypes *[]PduSessionType `json:"additionalAllowedSessionTypes,omitempty"` + AllocationAndRetentionPriorityLevel *int64 `json:"allocationAndRetentionPriorityLevel,omitempty"` + AllowedServices []ServiceResourceId `json:"allowedServices"` + DataNetwork DataNetworkResourceId `json:"dataNetwork"` + DefaultSessionType *PduSessionType `json:"defaultSessionType,omitempty"` + Fiveqi *int64 `json:"5qi,omitempty"` + MaximumNumberOfBufferedPackets *int64 `json:"maximumNumberOfBufferedPackets,omitempty"` + PreemptionCapability *PreemptionCapability `json:"preemptionCapability,omitempty"` + PreemptionVulnerability *PreemptionVulnerability `json:"preemptionVulnerability,omitempty"` + SessionAmbr Ambr `json:"sessionAmbr"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_datanetworkresourceid.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_datanetworkresourceid.go new file mode 100644 index 00000000000..8fb5c06c5e9 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_datanetworkresourceid.go @@ -0,0 +1,8 @@ +package simpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetworkResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_serviceresourceid.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_serviceresourceid.go new file mode 100644 index 00000000000..377b88b16f1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_serviceresourceid.go @@ -0,0 +1,8 @@ +package simpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_simpolicy.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_simpolicy.go new file mode 100644 index 00000000000..fd2477c15da --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_simpolicy.go @@ -0,0 +1,18 @@ +package simpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPolicy struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties SimPolicyPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_simpolicypropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_simpolicypropertiesformat.go new file mode 100644 index 00000000000..99027ce0c5d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_simpolicypropertiesformat.go @@ -0,0 +1,14 @@ +package simpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPolicyPropertiesFormat struct { + DefaultSlice SliceResourceId `json:"defaultSlice"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RegistrationTimer *int64 `json:"registrationTimer,omitempty"` + RfspIndex *int64 `json:"rfspIndex,omitempty"` + SiteProvisioningState *map[string]SiteProvisioningState `json:"siteProvisioningState,omitempty"` + SliceConfigurations []SliceConfiguration `json:"sliceConfigurations"` + UeAmbr Ambr `json:"ueAmbr"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_sliceconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_sliceconfiguration.go new file mode 100644 index 00000000000..9fdd8b95604 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_sliceconfiguration.go @@ -0,0 +1,10 @@ +package simpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SliceConfiguration struct { + DataNetworkConfigurations []DataNetworkConfiguration `json:"dataNetworkConfigurations"` + DefaultDataNetwork DataNetworkResourceId `json:"defaultDataNetwork"` + Slice SliceResourceId `json:"slice"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_sliceresourceid.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_sliceresourceid.go new file mode 100644 index 00000000000..f93e3af9c6a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/model_sliceresourceid.go @@ -0,0 +1,8 @@ +package simpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SliceResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/predicates.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/predicates.go new file mode 100644 index 00000000000..6f42f616168 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/predicates.go @@ -0,0 +1,32 @@ +package simpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPolicyOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SimPolicyOperationPredicate) Matches(input SimPolicy) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicies/version.go b/resource-manager/mobilenetwork/2024-04-01/simpolicies/version.go new file mode 100644 index 00000000000..ac5ed0846d5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicies/version.go @@ -0,0 +1,12 @@ +package simpolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/simpolicies/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/README.md b/resource-manager/mobilenetwork/2024-04-01/simpolicy/README.md new file mode 100644 index 00000000000..66a4c6fe224 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simpolicy` Documentation + +The `simpolicy` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/simpolicy" +``` + + +### Client Initialization + +```go +client := simpolicy.NewSIMPolicyClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SIMPolicyClient.SimPoliciesCreateOrUpdate` + +```go +ctx := context.TODO() +id := simpolicy.NewSimPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "simPolicyValue") + +payload := simpolicy.SimPolicy{ + // ... +} + + +if err := client.SimPoliciesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMPolicyClient.SimPoliciesDelete` + +```go +ctx := context.TODO() +id := simpolicy.NewSimPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "simPolicyValue") + +if err := client.SimPoliciesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMPolicyClient.SimPoliciesGet` + +```go +ctx := context.TODO() +id := simpolicy.NewSimPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "simPolicyValue") + +read, err := client.SimPoliciesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SIMPolicyClient.SimPoliciesUpdateTags` + +```go +ctx := context.TODO() +id := simpolicy.NewSimPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "simPolicyValue") + +payload := simpolicy.TagsObject{ + // ... +} + + +read, err := client.SimPoliciesUpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/client.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/client.go new file mode 100644 index 00000000000..b6a8741ef88 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/client.go @@ -0,0 +1,26 @@ +package simpolicy + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SIMPolicyClient struct { + Client *resourcemanager.Client +} + +func NewSIMPolicyClientWithBaseURI(sdkApi sdkEnv.Api) (*SIMPolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "simpolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SIMPolicyClient: %+v", err) + } + + return &SIMPolicyClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/constants.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/constants.go new file mode 100644 index 00000000000..94bfd00672f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/constants.go @@ -0,0 +1,242 @@ +package simpolicy + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PduSessionType string + +const ( + PduSessionTypeIPvFour PduSessionType = "IPv4" + PduSessionTypeIPvSix PduSessionType = "IPv6" +) + +func PossibleValuesForPduSessionType() []string { + return []string{ + string(PduSessionTypeIPvFour), + string(PduSessionTypeIPvSix), + } +} + +func (s *PduSessionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePduSessionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePduSessionType(input string) (*PduSessionType, error) { + vals := map[string]PduSessionType{ + "ipv4": PduSessionTypeIPvFour, + "ipv6": PduSessionTypeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PduSessionType(input) + return &out, nil +} + +type PreemptionCapability string + +const ( + PreemptionCapabilityMayPreempt PreemptionCapability = "MayPreempt" + PreemptionCapabilityNotPreempt PreemptionCapability = "NotPreempt" +) + +func PossibleValuesForPreemptionCapability() []string { + return []string{ + string(PreemptionCapabilityMayPreempt), + string(PreemptionCapabilityNotPreempt), + } +} + +func (s *PreemptionCapability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreemptionCapability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreemptionCapability(input string) (*PreemptionCapability, error) { + vals := map[string]PreemptionCapability{ + "maypreempt": PreemptionCapabilityMayPreempt, + "notpreempt": PreemptionCapabilityNotPreempt, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionCapability(input) + return &out, nil +} + +type PreemptionVulnerability string + +const ( + PreemptionVulnerabilityNotPreemptable PreemptionVulnerability = "NotPreemptable" + PreemptionVulnerabilityPreemptable PreemptionVulnerability = "Preemptable" +) + +func PossibleValuesForPreemptionVulnerability() []string { + return []string{ + string(PreemptionVulnerabilityNotPreemptable), + string(PreemptionVulnerabilityPreemptable), + } +} + +func (s *PreemptionVulnerability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreemptionVulnerability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreemptionVulnerability(input string) (*PreemptionVulnerability, error) { + vals := map[string]PreemptionVulnerability{ + "notpreemptable": PreemptionVulnerabilityNotPreemptable, + "preemptable": PreemptionVulnerabilityPreemptable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionVulnerability(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + 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 SiteProvisioningState string + +const ( + SiteProvisioningStateAdding SiteProvisioningState = "Adding" + SiteProvisioningStateDeleting SiteProvisioningState = "Deleting" + SiteProvisioningStateFailed SiteProvisioningState = "Failed" + SiteProvisioningStateNotApplicable SiteProvisioningState = "NotApplicable" + SiteProvisioningStateProvisioned SiteProvisioningState = "Provisioned" + SiteProvisioningStateUpdating SiteProvisioningState = "Updating" +) + +func PossibleValuesForSiteProvisioningState() []string { + return []string{ + string(SiteProvisioningStateAdding), + string(SiteProvisioningStateDeleting), + string(SiteProvisioningStateFailed), + string(SiteProvisioningStateNotApplicable), + string(SiteProvisioningStateProvisioned), + string(SiteProvisioningStateUpdating), + } +} + +func (s *SiteProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteProvisioningState(input string) (*SiteProvisioningState, error) { + vals := map[string]SiteProvisioningState{ + "adding": SiteProvisioningStateAdding, + "deleting": SiteProvisioningStateDeleting, + "failed": SiteProvisioningStateFailed, + "notapplicable": SiteProvisioningStateNotApplicable, + "provisioned": SiteProvisioningStateProvisioned, + "updating": SiteProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/id_simpolicy.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/id_simpolicy.go new file mode 100644 index 00000000000..ffd989be75a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/id_simpolicy.go @@ -0,0 +1,139 @@ +package simpolicy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SimPolicyId{}) +} + +var _ resourceids.ResourceId = &SimPolicyId{} + +// SimPolicyId is a struct representing the Resource ID for a Sim Policy +type SimPolicyId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string + SimPolicyName string +} + +// NewSimPolicyID returns a new SimPolicyId struct +func NewSimPolicyID(subscriptionId string, resourceGroupName string, mobileNetworkName string, simPolicyName string) SimPolicyId { + return SimPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + SimPolicyName: simPolicyName, + } +} + +// ParseSimPolicyID parses 'input' into a SimPolicyId +func ParseSimPolicyID(input string) (*SimPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&SimPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SimPolicyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSimPolicyIDInsensitively parses 'input' case-insensitively into a SimPolicyId +// note: this method should only be used for API response data and not user input +func ParseSimPolicyIDInsensitively(input string) (*SimPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&SimPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SimPolicyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SimPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + if id.SimPolicyName, ok = input.Parsed["simPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "simPolicyName", input) + } + + return nil +} + +// ValidateSimPolicyID checks that 'input' can be parsed as a Sim Policy ID +func ValidateSimPolicyID(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 := ParseSimPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sim Policy ID +func (id SimPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s/simPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName, id.SimPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sim Policy ID +func (id SimPolicyId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + resourceids.StaticSegment("staticSimPolicies", "simPolicies", "simPolicies"), + resourceids.UserSpecifiedSegment("simPolicyName", "simPolicyValue"), + } +} + +// String returns a human-readable description of this Sim Policy ID +func (id SimPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + fmt.Sprintf("Sim Policy Name: %q", id.SimPolicyName), + } + return fmt.Sprintf("Sim Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/id_simpolicy_test.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/id_simpolicy_test.go new file mode 100644 index 00000000000..f37bf2e2a0e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/id_simpolicy_test.go @@ -0,0 +1,327 @@ +package simpolicy + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SimPolicyId{} + +func TestNewSimPolicyID(t *testing.T) { + id := NewSimPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "simPolicyValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } + + if id.SimPolicyName != "simPolicyValue" { + t.Fatalf("Expected %q but got %q for Segment 'SimPolicyName'", id.SimPolicyName, "simPolicyValue") + } +} + +func TestFormatSimPolicyID(t *testing.T) { + actual := NewSimPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "simPolicyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/simPolicies/simPolicyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSimPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SimPolicyId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/simPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/simPolicies/simPolicyValue", + Expected: &SimPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + SimPolicyName: "simPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/simPolicies/simPolicyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSimPolicyID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.SimPolicyName != v.Expected.SimPolicyName { + t.Fatalf("Expected %q but got %q for SimPolicyName", v.Expected.SimPolicyName, actual.SimPolicyName) + } + + } +} + +func TestParseSimPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SimPolicyId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/simPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sImPoLiCiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/simPolicies/simPolicyValue", + Expected: &SimPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + SimPolicyName: "simPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/simPolicies/simPolicyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sImPoLiCiEs/sImPoLiCyVaLuE", + Expected: &SimPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + SimPolicyName: "sImPoLiCyVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sImPoLiCiEs/sImPoLiCyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSimPolicyIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.SimPolicyName != v.Expected.SimPolicyName { + t.Fatalf("Expected %q but got %q for SimPolicyName", v.Expected.SimPolicyName, actual.SimPolicyName) + } + + } +} + +func TestSegmentsForSimPolicyId(t *testing.T) { + segments := SimPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SimPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciescreateorupdate.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciescreateorupdate.go new file mode 100644 index 00000000000..d163f0208e4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciescreateorupdate.go @@ -0,0 +1,75 @@ +package simpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPoliciesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SimPolicy +} + +// SimPoliciesCreateOrUpdate ... +func (c SIMPolicyClient) SimPoliciesCreateOrUpdate(ctx context.Context, id SimPolicyId, input SimPolicy) (result SimPoliciesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SimPoliciesCreateOrUpdateThenPoll performs SimPoliciesCreateOrUpdate then polls until it's completed +func (c SIMPolicyClient) SimPoliciesCreateOrUpdateThenPoll(ctx context.Context, id SimPolicyId, input SimPolicy) error { + result, err := c.SimPoliciesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SimPoliciesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SimPoliciesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesdelete.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesdelete.go new file mode 100644 index 00000000000..e4773bcdd6d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesdelete.go @@ -0,0 +1,71 @@ +package simpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPoliciesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SimPoliciesDelete ... +func (c SIMPolicyClient) SimPoliciesDelete(ctx context.Context, id SimPolicyId) (result SimPoliciesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SimPoliciesDeleteThenPoll performs SimPoliciesDelete then polls until it's completed +func (c SIMPolicyClient) SimPoliciesDeleteThenPoll(ctx context.Context, id SimPolicyId) error { + result, err := c.SimPoliciesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing SimPoliciesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SimPoliciesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesget.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesget.go new file mode 100644 index 00000000000..e4dcc89e2df --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesget.go @@ -0,0 +1,54 @@ +package simpolicy + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPoliciesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SimPolicy +} + +// SimPoliciesGet ... +func (c SIMPolicyClient) SimPoliciesGet(ctx context.Context, id SimPolicyId) (result SimPoliciesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SimPolicy + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesupdatetags.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesupdatetags.go new file mode 100644 index 00000000000..dd132c078aa --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/method_simpoliciesupdatetags.go @@ -0,0 +1,58 @@ +package simpolicy + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPoliciesUpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SimPolicy +} + +// SimPoliciesUpdateTags ... +func (c SIMPolicyClient) SimPoliciesUpdateTags(ctx context.Context, id SimPolicyId, input TagsObject) (result SimPoliciesUpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SimPolicy + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_ambr.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_ambr.go new file mode 100644 index 00000000000..78a7675fa4c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_ambr.go @@ -0,0 +1,9 @@ +package simpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ambr struct { + Downlink string `json:"downlink"` + Uplink string `json:"uplink"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_datanetworkconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_datanetworkconfiguration.go new file mode 100644 index 00000000000..e3722bdc49b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_datanetworkconfiguration.go @@ -0,0 +1,17 @@ +package simpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetworkConfiguration struct { + AdditionalAllowedSessionTypes *[]PduSessionType `json:"additionalAllowedSessionTypes,omitempty"` + AllocationAndRetentionPriorityLevel *int64 `json:"allocationAndRetentionPriorityLevel,omitempty"` + AllowedServices []ServiceResourceId `json:"allowedServices"` + DataNetwork DataNetworkResourceId `json:"dataNetwork"` + DefaultSessionType *PduSessionType `json:"defaultSessionType,omitempty"` + Fiveqi *int64 `json:"5qi,omitempty"` + MaximumNumberOfBufferedPackets *int64 `json:"maximumNumberOfBufferedPackets,omitempty"` + PreemptionCapability *PreemptionCapability `json:"preemptionCapability,omitempty"` + PreemptionVulnerability *PreemptionVulnerability `json:"preemptionVulnerability,omitempty"` + SessionAmbr Ambr `json:"sessionAmbr"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_datanetworkresourceid.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_datanetworkresourceid.go new file mode 100644 index 00000000000..e43c849aafa --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_datanetworkresourceid.go @@ -0,0 +1,8 @@ +package simpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataNetworkResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_serviceresourceid.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_serviceresourceid.go new file mode 100644 index 00000000000..35e35bcde83 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_serviceresourceid.go @@ -0,0 +1,8 @@ +package simpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_simpolicy.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_simpolicy.go new file mode 100644 index 00000000000..2022334f77a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_simpolicy.go @@ -0,0 +1,18 @@ +package simpolicy + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPolicy struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties SimPolicyPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_simpolicypropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_simpolicypropertiesformat.go new file mode 100644 index 00000000000..bc6a543eefa --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_simpolicypropertiesformat.go @@ -0,0 +1,14 @@ +package simpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPolicyPropertiesFormat struct { + DefaultSlice SliceResourceId `json:"defaultSlice"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RegistrationTimer *int64 `json:"registrationTimer,omitempty"` + RfspIndex *int64 `json:"rfspIndex,omitempty"` + SiteProvisioningState *map[string]SiteProvisioningState `json:"siteProvisioningState,omitempty"` + SliceConfigurations []SliceConfiguration `json:"sliceConfigurations"` + UeAmbr Ambr `json:"ueAmbr"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_sliceconfiguration.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_sliceconfiguration.go new file mode 100644 index 00000000000..6b82c3d0448 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_sliceconfiguration.go @@ -0,0 +1,10 @@ +package simpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SliceConfiguration struct { + DataNetworkConfigurations []DataNetworkConfiguration `json:"dataNetworkConfigurations"` + DefaultDataNetwork DataNetworkResourceId `json:"defaultDataNetwork"` + Slice SliceResourceId `json:"slice"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_sliceresourceid.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_sliceresourceid.go new file mode 100644 index 00000000000..750a6136f4a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_sliceresourceid.go @@ -0,0 +1,8 @@ +package simpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SliceResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_tagsobject.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_tagsobject.go new file mode 100644 index 00000000000..e712563f1d4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/model_tagsobject.go @@ -0,0 +1,8 @@ +package simpolicy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/simpolicy/version.go b/resource-manager/mobilenetwork/2024-04-01/simpolicy/version.go new file mode 100644 index 00000000000..ae00e718187 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/simpolicy/version.go @@ -0,0 +1,12 @@ +package simpolicy + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/simpolicy/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/README.md b/resource-manager/mobilenetwork/2024-04-01/sims/README.md new file mode 100644 index 00000000000..2040c045198 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/README.md @@ -0,0 +1,122 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/sims` Documentation + +The `sims` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/sims" +``` + + +### Client Initialization + +```go +client := sims.NewSIMsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SIMsClient.BulkDelete` + +```go +ctx := context.TODO() +id := sims.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +payload := sims.SimDeleteList{ + // ... +} + + +if err := client.BulkDeleteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMsClient.BulkUpload` + +```go +ctx := context.TODO() +id := sims.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +payload := sims.SimUploadList{ + // ... +} + + +if err := client.BulkUploadThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMsClient.BulkUploadEncrypted` + +```go +ctx := context.TODO() +id := sims.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +payload := sims.EncryptedSimUploadList{ + // ... +} + + +if err := client.BulkUploadEncryptedThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMsClient.Clone` + +```go +ctx := context.TODO() +id := sims.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +payload := sims.SimClone{ + // ... +} + + +if err := client.CloneThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SIMsClient.ListByGroup` + +```go +ctx := context.TODO() +id := sims.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +// alternatively `client.ListByGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SIMsClient.Move` + +```go +ctx := context.TODO() +id := sims.NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + +payload := sims.SimMove{ + // ... +} + + +if err := client.MoveThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/client.go b/resource-manager/mobilenetwork/2024-04-01/sims/client.go new file mode 100644 index 00000000000..e74a1379d26 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/client.go @@ -0,0 +1,26 @@ +package sims + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SIMsClient struct { + Client *resourcemanager.Client +} + +func NewSIMsClientWithBaseURI(sdkApi sdkEnv.Api) (*SIMsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "sims", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SIMsClient: %+v", err) + } + + return &SIMsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/constants.go b/resource-manager/mobilenetwork/2024-04-01/sims/constants.go new file mode 100644 index 00000000000..1990ff62c69 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/constants.go @@ -0,0 +1,163 @@ +package sims + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + 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 SimState string + +const ( + SimStateDisabled SimState = "Disabled" + SimStateEnabled SimState = "Enabled" + SimStateInvalid SimState = "Invalid" +) + +func PossibleValuesForSimState() []string { + return []string{ + string(SimStateDisabled), + string(SimStateEnabled), + string(SimStateInvalid), + } +} + +func (s *SimState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSimState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSimState(input string) (*SimState, error) { + vals := map[string]SimState{ + "disabled": SimStateDisabled, + "enabled": SimStateEnabled, + "invalid": SimStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SimState(input) + return &out, nil +} + +type SiteProvisioningState string + +const ( + SiteProvisioningStateAdding SiteProvisioningState = "Adding" + SiteProvisioningStateDeleting SiteProvisioningState = "Deleting" + SiteProvisioningStateFailed SiteProvisioningState = "Failed" + SiteProvisioningStateNotApplicable SiteProvisioningState = "NotApplicable" + SiteProvisioningStateProvisioned SiteProvisioningState = "Provisioned" + SiteProvisioningStateUpdating SiteProvisioningState = "Updating" +) + +func PossibleValuesForSiteProvisioningState() []string { + return []string{ + string(SiteProvisioningStateAdding), + string(SiteProvisioningStateDeleting), + string(SiteProvisioningStateFailed), + string(SiteProvisioningStateNotApplicable), + string(SiteProvisioningStateProvisioned), + string(SiteProvisioningStateUpdating), + } +} + +func (s *SiteProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteProvisioningState(input string) (*SiteProvisioningState, error) { + vals := map[string]SiteProvisioningState{ + "adding": SiteProvisioningStateAdding, + "deleting": SiteProvisioningStateDeleting, + "failed": SiteProvisioningStateFailed, + "notapplicable": SiteProvisioningStateNotApplicable, + "provisioned": SiteProvisioningStateProvisioned, + "updating": SiteProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/id_simgroup.go b/resource-manager/mobilenetwork/2024-04-01/sims/id_simgroup.go new file mode 100644 index 00000000000..b76d96d5cfb --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/id_simgroup.go @@ -0,0 +1,130 @@ +package sims + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SimGroupId{}) +} + +var _ resourceids.ResourceId = &SimGroupId{} + +// SimGroupId is a struct representing the Resource ID for a Sim Group +type SimGroupId struct { + SubscriptionId string + ResourceGroupName string + SimGroupName string +} + +// NewSimGroupID returns a new SimGroupId struct +func NewSimGroupID(subscriptionId string, resourceGroupName string, simGroupName string) SimGroupId { + return SimGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SimGroupName: simGroupName, + } +} + +// ParseSimGroupID parses 'input' into a SimGroupId +func ParseSimGroupID(input string) (*SimGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SimGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SimGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSimGroupIDInsensitively parses 'input' case-insensitively into a SimGroupId +// note: this method should only be used for API response data and not user input +func ParseSimGroupIDInsensitively(input string) (*SimGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SimGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SimGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SimGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SimGroupName, ok = input.Parsed["simGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "simGroupName", input) + } + + return nil +} + +// ValidateSimGroupID checks that 'input' can be parsed as a Sim Group ID +func ValidateSimGroupID(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 := ParseSimGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sim Group ID +func (id SimGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/simGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SimGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sim Group ID +func (id SimGroupId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticSimGroups", "simGroups", "simGroups"), + resourceids.UserSpecifiedSegment("simGroupName", "simGroupValue"), + } +} + +// String returns a human-readable description of this Sim Group ID +func (id SimGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sim Group Name: %q", id.SimGroupName), + } + return fmt.Sprintf("Sim Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/id_simgroup_test.go b/resource-manager/mobilenetwork/2024-04-01/sims/id_simgroup_test.go new file mode 100644 index 00000000000..992f21a3407 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/id_simgroup_test.go @@ -0,0 +1,282 @@ +package sims + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SimGroupId{} + +func TestNewSimGroupID(t *testing.T) { + id := NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue") + + 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.SimGroupName != "simGroupValue" { + t.Fatalf("Expected %q but got %q for Segment 'SimGroupName'", id.SimGroupName, "simGroupValue") + } +} + +func TestFormatSimGroupID(t *testing.T) { + actual := NewSimGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "simGroupValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSimGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SimGroupId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue", + Expected: &SimGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SimGroupName: "simGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSimGroupID(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.SimGroupName != v.Expected.SimGroupName { + t.Fatalf("Expected %q but got %q for SimGroupName", v.Expected.SimGroupName, actual.SimGroupName) + } + + } +} + +func TestParseSimGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SimGroupId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/sImGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue", + Expected: &SimGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SimGroupName: "simGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/simGroups/simGroupValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/sImGrOuPs/sImGrOuPvAlUe", + Expected: &SimGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SimGroupName: "sImGrOuPvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/sImGrOuPs/sImGrOuPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSimGroupIDInsensitively(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.SimGroupName != v.Expected.SimGroupName { + t.Fatalf("Expected %q but got %q for SimGroupName", v.Expected.SimGroupName, actual.SimGroupName) + } + + } +} + +func TestSegmentsForSimGroupId(t *testing.T) { + segments := SimGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SimGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/method_bulkdelete.go b/resource-manager/mobilenetwork/2024-04-01/sims/method_bulkdelete.go new file mode 100644 index 00000000000..77352a9a347 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/method_bulkdelete.go @@ -0,0 +1,76 @@ +package sims + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BulkDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AsyncOperationStatus +} + +// BulkDelete ... +func (c SIMsClient) BulkDelete(ctx context.Context, id SimGroupId, input SimDeleteList) (result BulkDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteSims", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// BulkDeleteThenPoll performs BulkDelete then polls until it's completed +func (c SIMsClient) BulkDeleteThenPoll(ctx context.Context, id SimGroupId, input SimDeleteList) error { + result, err := c.BulkDelete(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BulkDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BulkDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/method_bulkupload.go b/resource-manager/mobilenetwork/2024-04-01/sims/method_bulkupload.go new file mode 100644 index 00000000000..2457c87cbfc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/method_bulkupload.go @@ -0,0 +1,75 @@ +package sims + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BulkUploadOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AsyncOperationStatus +} + +// BulkUpload ... +func (c SIMsClient) BulkUpload(ctx context.Context, id SimGroupId, input SimUploadList) (result BulkUploadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/uploadSims", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// BulkUploadThenPoll performs BulkUpload then polls until it's completed +func (c SIMsClient) BulkUploadThenPoll(ctx context.Context, id SimGroupId, input SimUploadList) error { + result, err := c.BulkUpload(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BulkUpload: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BulkUpload: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/method_bulkuploadencrypted.go b/resource-manager/mobilenetwork/2024-04-01/sims/method_bulkuploadencrypted.go new file mode 100644 index 00000000000..a44e5d6b373 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/method_bulkuploadencrypted.go @@ -0,0 +1,75 @@ +package sims + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BulkUploadEncryptedOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AsyncOperationStatus +} + +// BulkUploadEncrypted ... +func (c SIMsClient) BulkUploadEncrypted(ctx context.Context, id SimGroupId, input EncryptedSimUploadList) (result BulkUploadEncryptedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/uploadEncryptedSims", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// BulkUploadEncryptedThenPoll performs BulkUploadEncrypted then polls until it's completed +func (c SIMsClient) BulkUploadEncryptedThenPoll(ctx context.Context, id SimGroupId, input EncryptedSimUploadList) error { + result, err := c.BulkUploadEncrypted(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BulkUploadEncrypted: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BulkUploadEncrypted: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/method_clone.go b/resource-manager/mobilenetwork/2024-04-01/sims/method_clone.go new file mode 100644 index 00000000000..cd29cdbfbbf --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/method_clone.go @@ -0,0 +1,75 @@ +package sims + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloneOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AsyncOperationStatus +} + +// Clone ... +func (c SIMsClient) Clone(ctx context.Context, id SimGroupId, input SimClone) (result CloneOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cloneSims", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CloneThenPoll performs Clone then polls until it's completed +func (c SIMsClient) CloneThenPoll(ctx context.Context, id SimGroupId, input SimClone) error { + result, err := c.Clone(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Clone: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Clone: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/method_listbygroup.go b/resource-manager/mobilenetwork/2024-04-01/sims/method_listbygroup.go new file mode 100644 index 00000000000..981186d2249 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/method_listbygroup.go @@ -0,0 +1,91 @@ +package sims + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Sim +} + +type ListByGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Sim +} + +// ListByGroup ... +func (c SIMsClient) ListByGroup(ctx context.Context, id SimGroupId) (result ListByGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sims", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Sim `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByGroupComplete retrieves all the results into a single object +func (c SIMsClient) ListByGroupComplete(ctx context.Context, id SimGroupId) (ListByGroupCompleteResult, error) { + return c.ListByGroupCompleteMatchingPredicate(ctx, id, SimOperationPredicate{}) +} + +// ListByGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SIMsClient) ListByGroupCompleteMatchingPredicate(ctx context.Context, id SimGroupId, predicate SimOperationPredicate) (result ListByGroupCompleteResult, err error) { + items := make([]Sim, 0) + + resp, err := c.ListByGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/method_move.go b/resource-manager/mobilenetwork/2024-04-01/sims/method_move.go new file mode 100644 index 00000000000..7f22e70b571 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/method_move.go @@ -0,0 +1,75 @@ +package sims + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MoveOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AsyncOperationStatus +} + +// Move ... +func (c SIMsClient) Move(ctx context.Context, id SimGroupId, input SimMove) (result MoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/moveSims", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// MoveThenPoll performs Move then polls until it's completed +func (c SIMsClient) MoveThenPoll(ctx context.Context, id SimGroupId, input SimMove) error { + result, err := c.Move(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Move: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Move: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_asyncoperationstatus.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_asyncoperationstatus.go new file mode 100644 index 00000000000..9b5c955054d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_asyncoperationstatus.go @@ -0,0 +1,46 @@ +package sims + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AsyncOperationStatus struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PercentComplete *float64 `json:"percentComplete,omitempty"` + Properties *interface{} `json:"properties,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status string `json:"status"` +} + +func (o *AsyncOperationStatus) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AsyncOperationStatus) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AsyncOperationStatus) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_attacheddatanetworkresourceid.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_attacheddatanetworkresourceid.go new file mode 100644 index 00000000000..4254ad0c1cc --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_attacheddatanetworkresourceid.go @@ -0,0 +1,8 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedDataNetworkResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_encryptedsimpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_encryptedsimpropertiesformat.go new file mode 100644 index 00000000000..8d3e3ebe61d --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_encryptedsimpropertiesformat.go @@ -0,0 +1,18 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptedSimPropertiesFormat struct { + DeviceType *string `json:"deviceType,omitempty"` + EncryptedCredentials *string `json:"encryptedCredentials,omitempty"` + IntegratedCircuitCardIdentifier *string `json:"integratedCircuitCardIdentifier,omitempty"` + InternationalMobileSubscriberIdentity string `json:"internationalMobileSubscriberIdentity"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SimPolicy *SimPolicyResourceId `json:"simPolicy,omitempty"` + SimState *SimState `json:"simState,omitempty"` + SiteProvisioningState *map[string]SiteProvisioningState `json:"siteProvisioningState,omitempty"` + StaticIPConfiguration *[]SimStaticIPProperties `json:"staticIpConfiguration,omitempty"` + VendorKeyFingerprint *string `json:"vendorKeyFingerprint,omitempty"` + VendorName *string `json:"vendorName,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_encryptedsimuploadlist.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_encryptedsimuploadlist.go new file mode 100644 index 00000000000..57951cfd6c0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_encryptedsimuploadlist.go @@ -0,0 +1,13 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptedSimUploadList struct { + AzureKeyIdentifier int64 `json:"azureKeyIdentifier"` + EncryptedTransportKey string `json:"encryptedTransportKey"` + SignedTransportKey string `json:"signedTransportKey"` + Sims []SimNameAndEncryptedProperties `json:"sims"` + VendorKeyFingerprint string `json:"vendorKeyFingerprint"` + Version int64 `json:"version"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_erroradditionalinfo.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_erroradditionalinfo.go new file mode 100644 index 00000000000..14995ce5436 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_errordetail.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_errordetail.go new file mode 100644 index 00000000000..b44df86cf2c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_errordetail.go @@ -0,0 +1,12 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_sim.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_sim.go new file mode 100644 index 00000000000..59fe975eff1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_sim.go @@ -0,0 +1,16 @@ +package sims + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sim struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties SimPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simclone.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simclone.go new file mode 100644 index 00000000000..57c2ca57f14 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simclone.go @@ -0,0 +1,9 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimClone struct { + Sims *[]string `json:"sims,omitempty"` + TargetSimGroupId *SimGroupResourceId `json:"targetSimGroupId,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simdeletelist.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simdeletelist.go new file mode 100644 index 00000000000..c2d28b11984 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simdeletelist.go @@ -0,0 +1,8 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimDeleteList struct { + Sims []string `json:"sims"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simgroupresourceid.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simgroupresourceid.go new file mode 100644 index 00000000000..dcc2536a9d5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simgroupresourceid.go @@ -0,0 +1,8 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimGroupResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simmove.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simmove.go new file mode 100644 index 00000000000..ecfb1f93f9e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simmove.go @@ -0,0 +1,9 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimMove struct { + Sims *[]string `json:"sims,omitempty"` + TargetSimGroupId *SimGroupResourceId `json:"targetSimGroupId,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simnameandencryptedproperties.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simnameandencryptedproperties.go new file mode 100644 index 00000000000..f5ca815ff5e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simnameandencryptedproperties.go @@ -0,0 +1,9 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimNameAndEncryptedProperties struct { + Name string `json:"name"` + Properties EncryptedSimPropertiesFormat `json:"properties"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simnameandproperties.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simnameandproperties.go new file mode 100644 index 00000000000..f6723f6b753 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simnameandproperties.go @@ -0,0 +1,9 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimNameAndProperties struct { + Name string `json:"name"` + Properties SimPropertiesFormat `json:"properties"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simpolicyresourceid.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simpolicyresourceid.go new file mode 100644 index 00000000000..dfa6a5c956b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simpolicyresourceid.go @@ -0,0 +1,8 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPolicyResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simpropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simpropertiesformat.go new file mode 100644 index 00000000000..52badda59a8 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simpropertiesformat.go @@ -0,0 +1,19 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimPropertiesFormat struct { + AuthenticationKey *string `json:"authenticationKey,omitempty"` + DeviceType *string `json:"deviceType,omitempty"` + IntegratedCircuitCardIdentifier *string `json:"integratedCircuitCardIdentifier,omitempty"` + InternationalMobileSubscriberIdentity string `json:"internationalMobileSubscriberIdentity"` + OperatorKeyCode *string `json:"operatorKeyCode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SimPolicy *SimPolicyResourceId `json:"simPolicy,omitempty"` + SimState *SimState `json:"simState,omitempty"` + SiteProvisioningState *map[string]SiteProvisioningState `json:"siteProvisioningState,omitempty"` + StaticIPConfiguration *[]SimStaticIPProperties `json:"staticIpConfiguration,omitempty"` + VendorKeyFingerprint *string `json:"vendorKeyFingerprint,omitempty"` + VendorName *string `json:"vendorName,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simstaticipproperties.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simstaticipproperties.go new file mode 100644 index 00000000000..126650ecf7f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simstaticipproperties.go @@ -0,0 +1,10 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimStaticIPProperties struct { + AttachedDataNetwork *AttachedDataNetworkResourceId `json:"attachedDataNetwork,omitempty"` + Slice *SliceResourceId `json:"slice,omitempty"` + StaticIP *SimStaticIPPropertiesStaticIP `json:"staticIp,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simstaticippropertiesstaticip.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simstaticippropertiesstaticip.go new file mode 100644 index 00000000000..3f7211349e6 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simstaticippropertiesstaticip.go @@ -0,0 +1,8 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimStaticIPPropertiesStaticIP struct { + IPv4Address *string `json:"ipv4Address,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_simuploadlist.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_simuploadlist.go new file mode 100644 index 00000000000..bc073bb9c9e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_simuploadlist.go @@ -0,0 +1,8 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimUploadList struct { + Sims []SimNameAndProperties `json:"sims"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/model_sliceresourceid.go b/resource-manager/mobilenetwork/2024-04-01/sims/model_sliceresourceid.go new file mode 100644 index 00000000000..f2d1176f7ed --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/model_sliceresourceid.go @@ -0,0 +1,8 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SliceResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/predicates.go b/resource-manager/mobilenetwork/2024-04-01/sims/predicates.go new file mode 100644 index 00000000000..bf9181149d9 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/predicates.go @@ -0,0 +1,27 @@ +package sims + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SimOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SimOperationPredicate) Matches(input Sim) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sims/version.go b/resource-manager/mobilenetwork/2024-04-01/sims/version.go new file mode 100644 index 00000000000..fbb4e3a72d0 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sims/version.go @@ -0,0 +1,12 @@ +package sims + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/sims/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/README.md b/resource-manager/mobilenetwork/2024-04-01/site/README.md new file mode 100644 index 00000000000..9419d39b367 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/site` Documentation + +The `site` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/site" +``` + + +### Client Initialization + +```go +client := site.NewSiteClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SiteClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := site.NewSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "siteValue") + +payload := site.Site{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SiteClient.Delete` + +```go +ctx := context.TODO() +id := site.NewSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "siteValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SiteClient.DeletePacketCore` + +```go +ctx := context.TODO() +id := site.NewSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "siteValue") + +payload := site.SiteDeletePacketCore{ + // ... +} + + +if err := client.DeletePacketCoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SiteClient.Get` + +```go +ctx := context.TODO() +id := site.NewSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "siteValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SiteClient.UpdateTags` + +```go +ctx := context.TODO() +id := site.NewSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "siteValue") + +payload := site.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/site/client.go b/resource-manager/mobilenetwork/2024-04-01/site/client.go new file mode 100644 index 00000000000..9cd860565b2 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/client.go @@ -0,0 +1,26 @@ +package site + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteClient struct { + Client *resourcemanager.Client +} + +func NewSiteClientWithBaseURI(sdkApi sdkEnv.Api) (*SiteClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "site", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SiteClient: %+v", err) + } + + return &SiteClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/constants.go b/resource-manager/mobilenetwork/2024-04-01/site/constants.go new file mode 100644 index 00000000000..c486645f2e3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/constants.go @@ -0,0 +1,66 @@ +package site + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/id_site.go b/resource-manager/mobilenetwork/2024-04-01/site/id_site.go new file mode 100644 index 00000000000..9eddac47c82 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/id_site.go @@ -0,0 +1,139 @@ +package site + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteId{}) +} + +var _ resourceids.ResourceId = &SiteId{} + +// SiteId is a struct representing the Resource ID for a Site +type SiteId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string + SiteName string +} + +// NewSiteID returns a new SiteId struct +func NewSiteID(subscriptionId string, resourceGroupName string, mobileNetworkName string, siteName string) SiteId { + return SiteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + SiteName: siteName, + } +} + +// ParseSiteID parses 'input' into a SiteId +func ParseSiteID(input string) (*SiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteIDInsensitively parses 'input' case-insensitively into a SiteId +// note: this method should only be used for API response data and not user input +func ParseSiteIDInsensitively(input string) (*SiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + return nil +} + +// ValidateSiteID checks that 'input' can be parsed as a Site ID +func ValidateSiteID(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 := ParseSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site ID +func (id SiteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s/sites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName, id.SiteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site ID +func (id SiteId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + } +} + +// String returns a human-readable description of this Site ID +func (id SiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + fmt.Sprintf("Site Name: %q", id.SiteName), + } + return fmt.Sprintf("Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/id_site_test.go b/resource-manager/mobilenetwork/2024-04-01/site/id_site_test.go new file mode 100644 index 00000000000..ce93d5e52f3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/id_site_test.go @@ -0,0 +1,327 @@ +package site + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SiteId{} + +func TestNewSiteID(t *testing.T) { + id := NewSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "siteValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } + + if id.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } +} + +func TestFormatSiteID(t *testing.T) { + actual := NewSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "siteValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/sites/siteValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/sites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/sites/siteValue", + Expected: &SiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + SiteName: "siteValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/sites/siteValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + } +} + +func TestParseSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sItEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/sites/siteValue", + Expected: &SiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + SiteName: "siteValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/sites/siteValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sItEs/sItEvAlUe", + Expected: &SiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + SiteName: "sItEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sItEs/sItEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + } +} + +func TestSegmentsForSiteId(t *testing.T) { + segments := SiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/site/method_createorupdate.go new file mode 100644 index 00000000000..e85d2db3693 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/method_createorupdate.go @@ -0,0 +1,75 @@ +package site + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// CreateOrUpdate ... +func (c SiteClient) CreateOrUpdate(ctx context.Context, id SiteId, input Site) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SiteClient) CreateOrUpdateThenPoll(ctx context.Context, id SiteId, input Site) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/site/method_delete.go new file mode 100644 index 00000000000..7bf19e13f6a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/method_delete.go @@ -0,0 +1,71 @@ +package site + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SiteClient) Delete(ctx context.Context, id SiteId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SiteClient) DeleteThenPoll(ctx context.Context, id SiteId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/method_deletepacketcore.go b/resource-manager/mobilenetwork/2024-04-01/site/method_deletepacketcore.go new file mode 100644 index 00000000000..96f27fe7cda --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/method_deletepacketcore.go @@ -0,0 +1,74 @@ +package site + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePacketCoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePacketCore ... +func (c SiteClient) DeletePacketCore(ctx context.Context, id SiteId, input SiteDeletePacketCore) (result DeletePacketCoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deletePacketCore", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeletePacketCoreThenPoll performs DeletePacketCore then polls until it's completed +func (c SiteClient) DeletePacketCoreThenPoll(ctx context.Context, id SiteId, input SiteDeletePacketCore) error { + result, err := c.DeletePacketCore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeletePacketCore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePacketCore: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/method_get.go b/resource-manager/mobilenetwork/2024-04-01/site/method_get.go new file mode 100644 index 00000000000..d4bac52e0fa --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/method_get.go @@ -0,0 +1,54 @@ +package site + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// Get ... +func (c SiteClient) Get(ctx context.Context, id SiteId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Site + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/method_updatetags.go b/resource-manager/mobilenetwork/2024-04-01/site/method_updatetags.go new file mode 100644 index 00000000000..995a94bf857 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/method_updatetags.go @@ -0,0 +1,58 @@ +package site + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// UpdateTags ... +func (c SiteClient) UpdateTags(ctx context.Context, id SiteId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Site + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/model_packetcorecontrolplaneresourceid.go b/resource-manager/mobilenetwork/2024-04-01/site/model_packetcorecontrolplaneresourceid.go new file mode 100644 index 00000000000..1e4dda6a603 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/model_packetcorecontrolplaneresourceid.go @@ -0,0 +1,8 @@ +package site + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCoreControlPlaneResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/model_site.go b/resource-manager/mobilenetwork/2024-04-01/site/model_site.go new file mode 100644 index 00000000000..bd5f7fe6a7a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/model_site.go @@ -0,0 +1,18 @@ +package site + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Site struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SitePropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/model_sitedeletepacketcore.go b/resource-manager/mobilenetwork/2024-04-01/site/model_sitedeletepacketcore.go new file mode 100644 index 00000000000..c2aa2702d06 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/model_sitedeletepacketcore.go @@ -0,0 +1,8 @@ +package site + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDeletePacketCore struct { + PacketCore *PacketCoreControlPlaneResourceId `json:"packetCore,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/model_sitepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/site/model_sitepropertiesformat.go new file mode 100644 index 00000000000..8c4dd99fde4 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/model_sitepropertiesformat.go @@ -0,0 +1,9 @@ +package site + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePropertiesFormat struct { + NetworkFunctions *[]SubResource `json:"networkFunctions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/model_subresource.go b/resource-manager/mobilenetwork/2024-04-01/site/model_subresource.go new file mode 100644 index 00000000000..1c27266a311 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/model_subresource.go @@ -0,0 +1,8 @@ +package site + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/model_tagsobject.go b/resource-manager/mobilenetwork/2024-04-01/site/model_tagsobject.go new file mode 100644 index 00000000000..75ebb164c0a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/model_tagsobject.go @@ -0,0 +1,8 @@ +package site + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/site/version.go b/resource-manager/mobilenetwork/2024-04-01/site/version.go new file mode 100644 index 00000000000..333dc1edea6 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/site/version.go @@ -0,0 +1,12 @@ +package site + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/site/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/README.md b/resource-manager/mobilenetwork/2024-04-01/sites/README.md new file mode 100644 index 00000000000..ca1d438269f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/sites` Documentation + +The `sites` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/sites" +``` + + +### Client Initialization + +```go +client := sites.NewSitesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SitesClient.ListByMobileNetwork` + +```go +ctx := context.TODO() +id := sites.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +// alternatively `client.ListByMobileNetwork(ctx, id)` can be used to do batched pagination +items, err := client.ListByMobileNetworkComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/client.go b/resource-manager/mobilenetwork/2024-04-01/sites/client.go new file mode 100644 index 00000000000..3ab027d9c58 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/client.go @@ -0,0 +1,26 @@ +package sites + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitesClient struct { + Client *resourcemanager.Client +} + +func NewSitesClientWithBaseURI(sdkApi sdkEnv.Api) (*SitesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "sites", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SitesClient: %+v", err) + } + + return &SitesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/constants.go b/resource-manager/mobilenetwork/2024-04-01/sites/constants.go new file mode 100644 index 00000000000..ee3afd60afa --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/constants.go @@ -0,0 +1,66 @@ +package sites + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/id_mobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/sites/id_mobilenetwork.go new file mode 100644 index 00000000000..c8015f27277 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/id_mobilenetwork.go @@ -0,0 +1,130 @@ +package sites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MobileNetworkId{}) +} + +var _ resourceids.ResourceId = &MobileNetworkId{} + +// MobileNetworkId is a struct representing the Resource ID for a Mobile Network +type MobileNetworkId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string +} + +// NewMobileNetworkID returns a new MobileNetworkId struct +func NewMobileNetworkID(subscriptionId string, resourceGroupName string, mobileNetworkName string) MobileNetworkId { + return MobileNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + } +} + +// ParseMobileNetworkID parses 'input' into a MobileNetworkId +func ParseMobileNetworkID(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMobileNetworkIDInsensitively parses 'input' case-insensitively into a MobileNetworkId +// note: this method should only be used for API response data and not user input +func ParseMobileNetworkIDInsensitively(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MobileNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + return nil +} + +// ValidateMobileNetworkID checks that 'input' can be parsed as a Mobile Network ID +func ValidateMobileNetworkID(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 := ParseMobileNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mobile Network ID +func (id MobileNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mobile Network ID +func (id MobileNetworkId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + } +} + +// String returns a human-readable description of this Mobile Network ID +func (id MobileNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + } + return fmt.Sprintf("Mobile Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/id_mobilenetwork_test.go b/resource-manager/mobilenetwork/2024-04-01/sites/id_mobilenetwork_test.go new file mode 100644 index 00000000000..a1ef62b7db3 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/id_mobilenetwork_test.go @@ -0,0 +1,282 @@ +package sites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MobileNetworkId{} + +func TestNewMobileNetworkID(t *testing.T) { + id := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } +} + +func TestFormatMobileNetworkID(t *testing.T) { + actual := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMobileNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestParseMobileNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestSegmentsForMobileNetworkId(t *testing.T) { + segments := MobileNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MobileNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/method_listbymobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/sites/method_listbymobilenetwork.go new file mode 100644 index 00000000000..8d590b54bfd --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/method_listbymobilenetwork.go @@ -0,0 +1,91 @@ +package sites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByMobileNetworkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListByMobileNetworkCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +// ListByMobileNetwork ... +func (c SitesClient) ListByMobileNetwork(ctx context.Context, id MobileNetworkId) (result ListByMobileNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByMobileNetworkComplete retrieves all the results into a single object +func (c SitesClient) ListByMobileNetworkComplete(ctx context.Context, id MobileNetworkId) (ListByMobileNetworkCompleteResult, error) { + return c.ListByMobileNetworkCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) +} + +// ListByMobileNetworkCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SitesClient) ListByMobileNetworkCompleteMatchingPredicate(ctx context.Context, id MobileNetworkId, predicate SiteOperationPredicate) (result ListByMobileNetworkCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListByMobileNetwork(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByMobileNetworkCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/model_site.go b/resource-manager/mobilenetwork/2024-04-01/sites/model_site.go new file mode 100644 index 00000000000..b73fd5d7393 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/model_site.go @@ -0,0 +1,18 @@ +package sites + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Site struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SitePropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/model_sitepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/sites/model_sitepropertiesformat.go new file mode 100644 index 00000000000..c8bcfe3d14c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/model_sitepropertiesformat.go @@ -0,0 +1,9 @@ +package sites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePropertiesFormat struct { + NetworkFunctions *[]SubResource `json:"networkFunctions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/model_subresource.go b/resource-manager/mobilenetwork/2024-04-01/sites/model_subresource.go new file mode 100644 index 00000000000..6ef644da7bb --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/model_subresource.go @@ -0,0 +1,8 @@ +package sites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id string `json:"id"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/predicates.go b/resource-manager/mobilenetwork/2024-04-01/sites/predicates.go new file mode 100644 index 00000000000..0b1a7c0531c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/predicates.go @@ -0,0 +1,32 @@ +package sites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/sites/version.go b/resource-manager/mobilenetwork/2024-04-01/sites/version.go new file mode 100644 index 00000000000..79bb76a9c5e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/sites/version.go @@ -0,0 +1,12 @@ +package sites + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/sites/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/README.md b/resource-manager/mobilenetwork/2024-04-01/slice/README.md new file mode 100644 index 00000000000..71d9cc5dd07 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/slice` Documentation + +The `slice` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/slice" +``` + + +### Client Initialization + +```go +client := slice.NewSliceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SliceClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := slice.NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue") + +payload := slice.Slice{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SliceClient.Delete` + +```go +ctx := context.TODO() +id := slice.NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SliceClient.Get` + +```go +ctx := context.TODO() +id := slice.NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SliceClient.UpdateTags` + +```go +ctx := context.TODO() +id := slice.NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue") + +payload := slice.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/client.go b/resource-manager/mobilenetwork/2024-04-01/slice/client.go new file mode 100644 index 00000000000..554bd7acc02 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/client.go @@ -0,0 +1,26 @@ +package slice + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SliceClient struct { + Client *resourcemanager.Client +} + +func NewSliceClientWithBaseURI(sdkApi sdkEnv.Api) (*SliceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "slice", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SliceClient: %+v", err) + } + + return &SliceClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/constants.go b/resource-manager/mobilenetwork/2024-04-01/slice/constants.go new file mode 100644 index 00000000000..bfb5d6690a5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/constants.go @@ -0,0 +1,66 @@ +package slice + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/id_slice.go b/resource-manager/mobilenetwork/2024-04-01/slice/id_slice.go new file mode 100644 index 00000000000..735c1e9f3ed --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/id_slice.go @@ -0,0 +1,139 @@ +package slice + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SliceId{}) +} + +var _ resourceids.ResourceId = &SliceId{} + +// SliceId is a struct representing the Resource ID for a Slice +type SliceId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string + SliceName string +} + +// NewSliceID returns a new SliceId struct +func NewSliceID(subscriptionId string, resourceGroupName string, mobileNetworkName string, sliceName string) SliceId { + return SliceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + SliceName: sliceName, + } +} + +// ParseSliceID parses 'input' into a SliceId +func ParseSliceID(input string) (*SliceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SliceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SliceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSliceIDInsensitively parses 'input' case-insensitively into a SliceId +// note: this method should only be used for API response data and not user input +func ParseSliceIDInsensitively(input string) (*SliceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SliceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SliceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SliceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + if id.SliceName, ok = input.Parsed["sliceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sliceName", input) + } + + return nil +} + +// ValidateSliceID checks that 'input' can be parsed as a Slice ID +func ValidateSliceID(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 := ParseSliceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slice ID +func (id SliceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s/slices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName, id.SliceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slice ID +func (id SliceId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + resourceids.StaticSegment("staticSlices", "slices", "slices"), + resourceids.UserSpecifiedSegment("sliceName", "sliceValue"), + } +} + +// String returns a human-readable description of this Slice ID +func (id SliceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + fmt.Sprintf("Slice Name: %q", id.SliceName), + } + return fmt.Sprintf("Slice (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/id_slice_test.go b/resource-manager/mobilenetwork/2024-04-01/slice/id_slice_test.go new file mode 100644 index 00000000000..efebf55cf84 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/id_slice_test.go @@ -0,0 +1,327 @@ +package slice + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SliceId{} + +func TestNewSliceID(t *testing.T) { + id := NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } + + if id.SliceName != "sliceValue" { + t.Fatalf("Expected %q but got %q for Segment 'SliceName'", id.SliceName, "sliceValue") + } +} + +func TestFormatSliceID(t *testing.T) { + actual := NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/slices/sliceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSliceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SliceId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/slices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/slices/sliceValue", + Expected: &SliceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + SliceName: "sliceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/slices/sliceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSliceID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.SliceName != v.Expected.SliceName { + t.Fatalf("Expected %q but got %q for SliceName", v.Expected.SliceName, actual.SliceName) + } + + } +} + +func TestParseSliceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SliceId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/slices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sLiCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/slices/sliceValue", + Expected: &SliceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + SliceName: "sliceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/slices/sliceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sLiCeS/sLiCeVaLuE", + Expected: &SliceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + SliceName: "sLiCeVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/sLiCeS/sLiCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSliceIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + if actual.SliceName != v.Expected.SliceName { + t.Fatalf("Expected %q but got %q for SliceName", v.Expected.SliceName, actual.SliceName) + } + + } +} + +func TestSegmentsForSliceId(t *testing.T) { + segments := SliceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SliceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/method_createorupdate.go b/resource-manager/mobilenetwork/2024-04-01/slice/method_createorupdate.go new file mode 100644 index 00000000000..21ae4ef3d00 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/method_createorupdate.go @@ -0,0 +1,75 @@ +package slice + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Slice +} + +// CreateOrUpdate ... +func (c SliceClient) CreateOrUpdate(ctx context.Context, id SliceId, input Slice) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SliceClient) CreateOrUpdateThenPoll(ctx context.Context, id SliceId, input Slice) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/method_delete.go b/resource-manager/mobilenetwork/2024-04-01/slice/method_delete.go new file mode 100644 index 00000000000..0caf1ae8d6f --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/method_delete.go @@ -0,0 +1,71 @@ +package slice + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SliceClient) Delete(ctx context.Context, id SliceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SliceClient) DeleteThenPoll(ctx context.Context, id SliceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/method_get.go b/resource-manager/mobilenetwork/2024-04-01/slice/method_get.go new file mode 100644 index 00000000000..0b43d2deb19 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/method_get.go @@ -0,0 +1,54 @@ +package slice + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Slice +} + +// Get ... +func (c SliceClient) Get(ctx context.Context, id SliceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Slice + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/method_updatetags.go b/resource-manager/mobilenetwork/2024-04-01/slice/method_updatetags.go new file mode 100644 index 00000000000..faa019844ae --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/method_updatetags.go @@ -0,0 +1,58 @@ +package slice + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Slice +} + +// UpdateTags ... +func (c SliceClient) UpdateTags(ctx context.Context, id SliceId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Slice + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/model_slice.go b/resource-manager/mobilenetwork/2024-04-01/slice/model_slice.go new file mode 100644 index 00000000000..2ea70e26609 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/model_slice.go @@ -0,0 +1,18 @@ +package slice + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Slice struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties SlicePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/model_slicepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/slice/model_slicepropertiesformat.go new file mode 100644 index 00000000000..9af74336fee --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/model_slicepropertiesformat.go @@ -0,0 +1,10 @@ +package slice + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlicePropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Snssai Snssai `json:"snssai"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/model_snssai.go b/resource-manager/mobilenetwork/2024-04-01/slice/model_snssai.go new file mode 100644 index 00000000000..d52cf0ef4ff --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/model_snssai.go @@ -0,0 +1,9 @@ +package slice + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snssai struct { + Sd *string `json:"sd,omitempty"` + Sst int64 `json:"sst"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/model_tagsobject.go b/resource-manager/mobilenetwork/2024-04-01/slice/model_tagsobject.go new file mode 100644 index 00000000000..a6e5718ffcd --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/model_tagsobject.go @@ -0,0 +1,8 @@ +package slice + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slice/version.go b/resource-manager/mobilenetwork/2024-04-01/slice/version.go new file mode 100644 index 00000000000..6c12d0af4b1 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slice/version.go @@ -0,0 +1,12 @@ +package slice + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/slice/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/README.md b/resource-manager/mobilenetwork/2024-04-01/slices/README.md new file mode 100644 index 00000000000..f77c39d279e --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/slices` Documentation + +The `slices` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/slices" +``` + + +### Client Initialization + +```go +client := slices.NewSlicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SlicesClient.ListByMobileNetwork` + +```go +ctx := context.TODO() +id := slices.NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + +// alternatively `client.ListByMobileNetwork(ctx, id)` can be used to do batched pagination +items, err := client.ListByMobileNetworkComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/client.go b/resource-manager/mobilenetwork/2024-04-01/slices/client.go new file mode 100644 index 00000000000..1f866fe2398 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/client.go @@ -0,0 +1,26 @@ +package slices + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlicesClient struct { + Client *resourcemanager.Client +} + +func NewSlicesClientWithBaseURI(sdkApi sdkEnv.Api) (*SlicesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "slices", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SlicesClient: %+v", err) + } + + return &SlicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/constants.go b/resource-manager/mobilenetwork/2024-04-01/slices/constants.go new file mode 100644 index 00000000000..17af5fe15d5 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/constants.go @@ -0,0 +1,66 @@ +package slices + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/id_mobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/slices/id_mobilenetwork.go new file mode 100644 index 00000000000..d1c5c1d405b --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/id_mobilenetwork.go @@ -0,0 +1,130 @@ +package slices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MobileNetworkId{}) +} + +var _ resourceids.ResourceId = &MobileNetworkId{} + +// MobileNetworkId is a struct representing the Resource ID for a Mobile Network +type MobileNetworkId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string +} + +// NewMobileNetworkID returns a new MobileNetworkId struct +func NewMobileNetworkID(subscriptionId string, resourceGroupName string, mobileNetworkName string) MobileNetworkId { + return MobileNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + } +} + +// ParseMobileNetworkID parses 'input' into a MobileNetworkId +func ParseMobileNetworkID(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMobileNetworkIDInsensitively parses 'input' case-insensitively into a MobileNetworkId +// note: this method should only be used for API response data and not user input +func ParseMobileNetworkIDInsensitively(input string) (*MobileNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&MobileNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MobileNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MobileNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MobileNetworkName, ok = input.Parsed["mobileNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "mobileNetworkName", input) + } + + return nil +} + +// ValidateMobileNetworkID checks that 'input' can be parsed as a Mobile Network ID +func ValidateMobileNetworkID(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 := ParseMobileNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mobile Network ID +func (id MobileNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mobile Network ID +func (id MobileNetworkId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + } +} + +// String returns a human-readable description of this Mobile Network ID +func (id MobileNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + } + return fmt.Sprintf("Mobile Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/id_mobilenetwork_test.go b/resource-manager/mobilenetwork/2024-04-01/slices/id_mobilenetwork_test.go new file mode 100644 index 00000000000..99ccf76d395 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/id_mobilenetwork_test.go @@ -0,0 +1,282 @@ +package slices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MobileNetworkId{} + +func TestNewMobileNetworkID(t *testing.T) { + id := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue") + + 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.MobileNetworkName != "mobileNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'MobileNetworkName'", id.MobileNetworkName, "mobileNetworkValue") + } +} + +func TestFormatMobileNetworkID(t *testing.T) { + actual := NewMobileNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMobileNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkID(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestParseMobileNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MobileNetworkId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MobileNetworkName: "mobileNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE", + Expected: &MobileNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MobileNetworkName: "mObIlEnEtWoRkVaLuE", + }, + }, + { + // 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.mObIlEnEtWoRk/mObIlEnEtWoRkS/mObIlEnEtWoRkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMobileNetworkIDInsensitively(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.MobileNetworkName != v.Expected.MobileNetworkName { + t.Fatalf("Expected %q but got %q for MobileNetworkName", v.Expected.MobileNetworkName, actual.MobileNetworkName) + } + + } +} + +func TestSegmentsForMobileNetworkId(t *testing.T) { + segments := MobileNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MobileNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/method_listbymobilenetwork.go b/resource-manager/mobilenetwork/2024-04-01/slices/method_listbymobilenetwork.go new file mode 100644 index 00000000000..efd01a03648 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/method_listbymobilenetwork.go @@ -0,0 +1,91 @@ +package slices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByMobileNetworkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Slice +} + +type ListByMobileNetworkCompleteResult struct { + LatestHttpResponse *http.Response + Items []Slice +} + +// ListByMobileNetwork ... +func (c SlicesClient) ListByMobileNetwork(ctx context.Context, id MobileNetworkId) (result ListByMobileNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/slices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Slice `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByMobileNetworkComplete retrieves all the results into a single object +func (c SlicesClient) ListByMobileNetworkComplete(ctx context.Context, id MobileNetworkId) (ListByMobileNetworkCompleteResult, error) { + return c.ListByMobileNetworkCompleteMatchingPredicate(ctx, id, SliceOperationPredicate{}) +} + +// ListByMobileNetworkCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SlicesClient) ListByMobileNetworkCompleteMatchingPredicate(ctx context.Context, id MobileNetworkId, predicate SliceOperationPredicate) (result ListByMobileNetworkCompleteResult, err error) { + items := make([]Slice, 0) + + resp, err := c.ListByMobileNetwork(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByMobileNetworkCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/model_slice.go b/resource-manager/mobilenetwork/2024-04-01/slices/model_slice.go new file mode 100644 index 00000000000..5b95c569483 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/model_slice.go @@ -0,0 +1,18 @@ +package slices + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Slice struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties SlicePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/model_slicepropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/slices/model_slicepropertiesformat.go new file mode 100644 index 00000000000..0f74e861665 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/model_slicepropertiesformat.go @@ -0,0 +1,10 @@ +package slices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlicePropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Snssai Snssai `json:"snssai"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/model_snssai.go b/resource-manager/mobilenetwork/2024-04-01/slices/model_snssai.go new file mode 100644 index 00000000000..0f95a994a5a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/model_snssai.go @@ -0,0 +1,9 @@ +package slices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snssai struct { + Sd *string `json:"sd,omitempty"` + Sst int64 `json:"sst"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/predicates.go b/resource-manager/mobilenetwork/2024-04-01/slices/predicates.go new file mode 100644 index 00000000000..939ec9408b6 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/predicates.go @@ -0,0 +1,32 @@ +package slices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SliceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SliceOperationPredicate) Matches(input Slice) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/slices/version.go b/resource-manager/mobilenetwork/2024-04-01/slices/version.go new file mode 100644 index 00000000000..98523561f74 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/slices/version.go @@ -0,0 +1,12 @@ +package slices + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/slices/%s", defaultApiVersion) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/README.md b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/README.md new file mode 100644 index 00000000000..3a9638d1f59 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/ueinformationlist` Documentation + +The `ueinformationlist` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2024-04-01/ueinformationlist" +``` + + +### Client Initialization + +```go +client := ueinformationlist.NewUeInformationListClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `UeInformationListClient.UeInformationList` + +```go +ctx := context.TODO() +id := ueinformationlist.NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + +// alternatively `client.UeInformationList(ctx, id)` can be used to do batched pagination +items, err := client.UeInformationListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/client.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/client.go new file mode 100644 index 00000000000..8e4dde0f9fd --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/client.go @@ -0,0 +1,26 @@ +package ueinformationlist + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeInformationListClient struct { + Client *resourcemanager.Client +} + +func NewUeInformationListClientWithBaseURI(sdkApi sdkEnv.Api) (*UeInformationListClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "ueinformationlist", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UeInformationListClient: %+v", err) + } + + return &UeInformationListClient{ + Client: client, + }, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/constants.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/constants.go new file mode 100644 index 00000000000..8701edfaba9 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/constants.go @@ -0,0 +1,101 @@ +package ueinformationlist + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RatType string + +const ( + RatTypeFiveG RatType = "5G" + RatTypeFourG RatType = "4G" +) + +func PossibleValuesForRatType() []string { + return []string{ + string(RatTypeFiveG), + string(RatTypeFourG), + } +} + +func (s *RatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRatType(input string) (*RatType, error) { + vals := map[string]RatType{ + "5g": RatTypeFiveG, + "4g": RatTypeFourG, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RatType(input) + return &out, nil +} + +type UeState string + +const ( + UeStateConnected UeState = "Connected" + UeStateDeregistered UeState = "Deregistered" + UeStateDetached UeState = "Detached" + UeStateIdle UeState = "Idle" + UeStateUnknown UeState = "Unknown" +) + +func PossibleValuesForUeState() []string { + return []string{ + string(UeStateConnected), + string(UeStateDeregistered), + string(UeStateDetached), + string(UeStateIdle), + string(UeStateUnknown), + } +} + +func (s *UeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUeState(input string) (*UeState, error) { + vals := map[string]UeState{ + "connected": UeStateConnected, + "deregistered": UeStateDeregistered, + "detached": UeStateDetached, + "idle": UeStateIdle, + "unknown": UeStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UeState(input) + return &out, nil +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/id_packetcorecontrolplane.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/id_packetcorecontrolplane.go new file mode 100644 index 00000000000..9b7cb47ca7c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/id_packetcorecontrolplane.go @@ -0,0 +1,130 @@ +package ueinformationlist + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCoreControlPlaneId{}) +} + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +// PacketCoreControlPlaneId is a struct representing the Resource ID for a Packet Core Control Plane +type PacketCoreControlPlaneId struct { + SubscriptionId string + ResourceGroupName string + PacketCoreControlPlaneName string +} + +// NewPacketCoreControlPlaneID returns a new PacketCoreControlPlaneId struct +func NewPacketCoreControlPlaneID(subscriptionId string, resourceGroupName string, packetCoreControlPlaneName string) PacketCoreControlPlaneId { + return PacketCoreControlPlaneId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PacketCoreControlPlaneName: packetCoreControlPlaneName, + } +} + +// ParsePacketCoreControlPlaneID parses 'input' into a PacketCoreControlPlaneId +func ParsePacketCoreControlPlaneID(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCoreControlPlaneIDInsensitively parses 'input' case-insensitively into a PacketCoreControlPlaneId +// note: this method should only be used for API response data and not user input +func ParsePacketCoreControlPlaneIDInsensitively(input string) (*PacketCoreControlPlaneId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCoreControlPlaneId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCoreControlPlaneId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCoreControlPlaneId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PacketCoreControlPlaneName, ok = input.Parsed["packetCoreControlPlaneName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCoreControlPlaneName", input) + } + + return nil +} + +// ValidatePacketCoreControlPlaneID checks that 'input' can be parsed as a Packet Core Control Plane ID +func ValidatePacketCoreControlPlaneID(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 := ParsePacketCoreControlPlaneID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PacketCoreControlPlaneName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticPacketCoreControlPlanes", "packetCoreControlPlanes", "packetCoreControlPlanes"), + resourceids.UserSpecifiedSegment("packetCoreControlPlaneName", "packetCoreControlPlaneValue"), + } +} + +// String returns a human-readable description of this Packet Core Control Plane ID +func (id PacketCoreControlPlaneId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Packet Core Control Plane Name: %q", id.PacketCoreControlPlaneName), + } + return fmt.Sprintf("Packet Core Control Plane (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/id_packetcorecontrolplane_test.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/id_packetcorecontrolplane_test.go new file mode 100644 index 00000000000..5dcb294a19c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/id_packetcorecontrolplane_test.go @@ -0,0 +1,282 @@ +package ueinformationlist + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCoreControlPlaneId{} + +func TestNewPacketCoreControlPlaneID(t *testing.T) { + id := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue") + + 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.PacketCoreControlPlaneName != "packetCoreControlPlaneValue" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCoreControlPlaneName'", id.PacketCoreControlPlaneName, "packetCoreControlPlaneValue") + } +} + +func TestFormatPacketCoreControlPlaneID(t *testing.T) { + actual := NewPacketCoreControlPlaneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "packetCoreControlPlaneValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCoreControlPlaneID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneID(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestParsePacketCoreControlPlaneIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCoreControlPlaneId + }{ + { + // 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.MobileNetwork", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PacketCoreControlPlaneName: "packetCoreControlPlaneValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/packetCoreControlPlaneValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe", + Expected: &PacketCoreControlPlaneId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PacketCoreControlPlaneName: "pAcKeTcOrEcOnTrOlPlAnEvAlUe", + }, + }, + { + // 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.mObIlEnEtWoRk/pAcKeTcOrEcOnTrOlPlAnEs/pAcKeTcOrEcOnTrOlPlAnEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCoreControlPlaneIDInsensitively(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.PacketCoreControlPlaneName != v.Expected.PacketCoreControlPlaneName { + t.Fatalf("Expected %q but got %q for PacketCoreControlPlaneName", v.Expected.PacketCoreControlPlaneName, actual.PacketCoreControlPlaneName) + } + + } +} + +func TestSegmentsForPacketCoreControlPlaneId(t *testing.T) { + segments := PacketCoreControlPlaneId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCoreControlPlaneId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/method_ueinformationlist.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/method_ueinformationlist.go new file mode 100644 index 00000000000..a33421590c2 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/method_ueinformationlist.go @@ -0,0 +1,91 @@ +package ueinformationlist + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeInformationListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]UeInfo +} + +type UeInformationListCompleteResult struct { + LatestHttpResponse *http.Response + Items []UeInfo +} + +// UeInformationList ... +func (c UeInformationListClient) UeInformationList(ctx context.Context, id PacketCoreControlPlaneId) (result UeInformationListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/ues", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]UeInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// UeInformationListComplete retrieves all the results into a single object +func (c UeInformationListClient) UeInformationListComplete(ctx context.Context, id PacketCoreControlPlaneId) (UeInformationListCompleteResult, error) { + return c.UeInformationListCompleteMatchingPredicate(ctx, id, UeInfoOperationPredicate{}) +} + +// UeInformationListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UeInformationListClient) UeInformationListCompleteMatchingPredicate(ctx context.Context, id PacketCoreControlPlaneId, predicate UeInfoOperationPredicate) (result UeInformationListCompleteResult, err error) { + items := make([]UeInfo, 0) + + resp, err := c.UeInformationList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = UeInformationListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_dnnippair.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_dnnippair.go new file mode 100644 index 00000000000..32e98427800 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_dnnippair.go @@ -0,0 +1,9 @@ +package ueinformationlist + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnnIPPair struct { + Dnn *string `json:"dnn,omitempty"` + UeIPAddress *UeIPAddress `json:"ueIpAddress,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueinfo.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueinfo.go new file mode 100644 index 00000000000..bbe036b2562 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueinfo.go @@ -0,0 +1,16 @@ +package ueinformationlist + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeInfo struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties UeInfoPropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueinfopropertiesformat.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueinfopropertiesformat.go new file mode 100644 index 00000000000..72fa9ce5a3a --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueinfopropertiesformat.go @@ -0,0 +1,29 @@ +package ueinformationlist + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeInfoPropertiesFormat struct { + LastReadAt *string `json:"lastReadAt,omitempty"` + RatType RatType `json:"ratType"` + UeIPAddresses *[]DnnIPPair `json:"ueIpAddresses,omitempty"` + UeState UeState `json:"ueState"` +} + +func (o *UeInfoPropertiesFormat) GetLastReadAtAsTime() (*time.Time, error) { + if o.LastReadAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastReadAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *UeInfoPropertiesFormat) SetLastReadAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastReadAt = &formatted +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueipaddress.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueipaddress.go new file mode 100644 index 00000000000..3921d292cb6 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/model_ueipaddress.go @@ -0,0 +1,8 @@ +package ueinformationlist + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeIPAddress struct { + IPV4Addr *string `json:"ipV4Addr,omitempty"` +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/predicates.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/predicates.go new file mode 100644 index 00000000000..97bf26e7a6c --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/predicates.go @@ -0,0 +1,27 @@ +package ueinformationlist + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UeInfoOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p UeInfoOperationPredicate) Matches(input UeInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/version.go b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/version.go new file mode 100644 index 00000000000..0be13eee018 --- /dev/null +++ b/resource-manager/mobilenetwork/2024-04-01/ueinformationlist/version.go @@ -0,0 +1,12 @@ +package ueinformationlist + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/ueinformationlist/%s", defaultApiVersion) +}