diff --git a/sdk/resourcemanager/eventhub/armeventhub/assets.json b/sdk/resourcemanager/eventhub/armeventhub/assets.json index 7424094e97a0..0368812f7eee 100644 --- a/sdk/resourcemanager/eventhub/armeventhub/assets.json +++ b/sdk/resourcemanager/eventhub/armeventhub/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/resourcemanager/eventhub/armeventhub", - "Tag": "go/resourcemanager/eventhub/armeventhub_05a4cd540a" + "Tag": "go/resourcemanager/eventhub/armeventhub_98cad0dc15" } diff --git a/sdk/resourcemanager/eventhub/armeventhub/disasterrecoveryconfigs_live_test.go b/sdk/resourcemanager/eventhub/armeventhub/disasterrecoveryconfigs_live_test.go index 54bab7d31945..eb698fc09059 100644 --- a/sdk/resourcemanager/eventhub/armeventhub/disasterrecoveryconfigs_live_test.go +++ b/sdk/resourcemanager/eventhub/armeventhub/disasterrecoveryconfigs_live_test.go @@ -14,6 +14,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" "github.com/stretchr/testify/suite" @@ -39,10 +40,10 @@ func (testsuite *DisasterrecoveryconfigsTestSuite) SetupSuite() { testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/eventhub/armeventhub/testdata") testsuite.ctx = context.Background() testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) - testsuite.alias = testutil.GenerateAlphaNumericID(testsuite.T(), "alias2", 6) - testsuite.authorizationRuleName = testutil.GenerateAlphaNumericID(testsuite.T(), "authorizat2", 6) - testsuite.namespaceName = testutil.GenerateAlphaNumericID(testsuite.T(), "namespacen2", 6) - testsuite.namespaceNameSecond = testutil.GenerateAlphaNumericID(testsuite.T(), "namespacensecond", 6) + testsuite.alias, _ = recording.GenerateAlphaNumericID(testsuite.T(), "alias", 11, false) + testsuite.authorizationRuleName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "authorizat", 16, false) + testsuite.namespaceName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "namespacen", 16, false) + testsuite.namespaceNameSecond, _ = recording.GenerateAlphaNumericID(testsuite.T(), "namespacensecond", 22, false) testsuite.location = testutil.GetEnv("LOCATION", "westus") testsuite.resourceGroupName = testutil.GetEnv("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") testsuite.subscriptionId = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") diff --git a/sdk/resourcemanager/eventhub/armeventhub/eventhub_live_test.go b/sdk/resourcemanager/eventhub/armeventhub/eventhub_live_test.go index c69fa9f2207c..dfac34291280 100644 --- a/sdk/resourcemanager/eventhub/armeventhub/eventhub_live_test.go +++ b/sdk/resourcemanager/eventhub/armeventhub/eventhub_live_test.go @@ -14,6 +14,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" @@ -43,12 +44,12 @@ func (testsuite *EventhubTestSuite) SetupSuite() { testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/eventhub/armeventhub/testdata") testsuite.ctx = context.Background() testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) - testsuite.applicationGroupName = testutil.GenerateAlphaNumericID(testsuite.T(), "applicatio", 6) - testsuite.authorizationRuleName = testutil.GenerateAlphaNumericID(testsuite.T(), "authorizat", 6) - testsuite.consumerGroupName = testutil.GenerateAlphaNumericID(testsuite.T(), "consumergr", 6) - testsuite.eventHubName = testutil.GenerateAlphaNumericID(testsuite.T(), "eventhubna", 6) - testsuite.namespaceName = testutil.GenerateAlphaNumericID(testsuite.T(), "namespacen", 6) - testsuite.schemaGroupName = testutil.GenerateAlphaNumericID(testsuite.T(), "schemagrou", 6) + testsuite.applicationGroupName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "applicatio", 16, false) + testsuite.authorizationRuleName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "authorizat", 16, false) + testsuite.consumerGroupName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "consumergr", 16, false) + testsuite.eventHubName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "eventhubna", 16, false) + testsuite.namespaceName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "namespacen", 16, false) + testsuite.schemaGroupName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "schemagrou", 16, false) testsuite.storageAccountName = "storageeventhub2" testsuite.location = testutil.GetEnv("LOCATION", "westus") testsuite.resourceGroupName = testutil.GetEnv("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") diff --git a/sdk/resourcemanager/eventhub/armeventhub/privateendpointconnections_live_test.go b/sdk/resourcemanager/eventhub/armeventhub/privateendpointconnections_live_test.go new file mode 100644 index 000000000000..0d88b84d568f --- /dev/null +++ b/sdk/resourcemanager/eventhub/armeventhub/privateendpointconnections_live_test.go @@ -0,0 +1,245 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armeventhub_test + +import ( + "context" + "fmt" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/stretchr/testify/suite" +) + +type PrivateEndpointConnectionsTestSuite struct { + suite.Suite + + ctx context.Context + cred azcore.TokenCredential + options *arm.ClientOptions + namespaceId string + namespaceName string + location string + resourceGroupName string + subscriptionId string +} + +func (testsuite *PrivateEndpointConnectionsTestSuite) SetupSuite() { + testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/eventhub/armeventhub/testdata") + + testsuite.ctx = context.Background() + testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) + testsuite.namespaceName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "namespac", 14, false) + testsuite.location = testutil.GetEnv("LOCATION", "westus") + testsuite.resourceGroupName = testutil.GetEnv("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) + testsuite.Require().NoError(err) + testsuite.resourceGroupName = *resourceGroup.Name + testsuite.Prepare() +} + +func (testsuite *PrivateEndpointConnectionsTestSuite) TearDownSuite() { + _, err := testutil.DeleteResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName) + testsuite.Require().NoError(err) + testutil.StopRecording(testsuite.T()) +} + +func TestPrivateEndpointConnectionsTestSuite(t *testing.T) { + suite.Run(t, new(PrivateEndpointConnectionsTestSuite)) +} + +func (testsuite *PrivateEndpointConnectionsTestSuite) Prepare() { + var err error + // From step Namespaces_CreateOrUpdate + fmt.Println("Call operation: Namespaces_CreateOrUpdate") + namespacesClient, err := armeventhub.NewNamespacesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + namespacesClientCreateOrUpdateResponsePoller, err := namespacesClient.BeginCreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.namespaceName, armeventhub.EHNamespace{ + Location: to.Ptr(testsuite.location), + SKU: &armeventhub.SKU{ + Name: to.Ptr(armeventhub.SKUNamePremium), + Tier: to.Ptr(armeventhub.SKUTierPremium), + }, + }, nil) + testsuite.Require().NoError(err) + var namespacesClientCreateOrUpdateResponse *armeventhub.NamespacesClientCreateOrUpdateResponse + namespacesClientCreateOrUpdateResponse, err = testutil.PollForTest(testsuite.ctx, namespacesClientCreateOrUpdateResponsePoller) + testsuite.Require().NoError(err) + testsuite.namespaceId = *namespacesClientCreateOrUpdateResponse.ID + + // From step Create_PrivateEndpoint + template := map[string]any{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": map[string]any{ + "location": map[string]any{ + "type": "string", + "defaultValue": testsuite.location, + }, + "namespaceId": map[string]any{ + "type": "string", + "defaultValue": testsuite.namespaceId, + }, + "networkInterfaceName": map[string]any{ + "type": "string", + "defaultValue": "peeventhub-nic", + }, + "privateEndpointName": map[string]any{ + "type": "string", + "defaultValue": "peeventhub", + }, + "virtualNetworksName": map[string]any{ + "type": "string", + "defaultValue": "peeventhubvnet", + }, + }, + "resources": []any{ + map[string]any{ + "name": "[parameters('virtualNetworksName')]", + "type": "Microsoft.Network/virtualNetworks", + "apiVersion": "2020-11-01", + "location": "[parameters('location')]", + "properties": map[string]any{ + "addressSpace": map[string]any{ + "addressPrefixes": []any{ + "10.0.0.0/16", + }, + }, + "enableDdosProtection": false, + "subnets": []any{ + map[string]any{ + "name": "default", + "properties": map[string]any{ + "addressPrefix": "10.0.0.0/24", + "delegations": []any{}, + "privateEndpointNetworkPolicies": "Enabled", + "privateLinkServiceNetworkPolicies": "Enabled", + }, + }, + }, + "virtualNetworkPeerings": []any{}, + }, + }, + map[string]any{ + "name": "[parameters('networkInterfaceName')]", + "type": "Microsoft.Network/networkInterfaces", + "apiVersion": "2020-11-01", + "dependsOn": []any{ + "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworksName'))]", + }, + "location": "[parameters('location')]", + "properties": map[string]any{ + "dnsSettings": map[string]any{ + "dnsServers": []any{}, + }, + "enableIPForwarding": false, + "ipConfigurations": []any{ + map[string]any{ + "name": "privateEndpointIpConfig", + "properties": map[string]any{ + "primary": true, + "privateIPAddress": "10.0.0.4", + "privateIPAddressVersion": "IPv4", + "privateIPAllocationMethod": "Dynamic", + "subnet": map[string]any{ + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", + }, + }, + }, + }, + }, + }, + map[string]any{ + "name": "[parameters('privateEndpointName')]", + "type": "Microsoft.Network/privateEndpoints", + "apiVersion": "2020-11-01", + "dependsOn": []any{ + "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworksName'))]", + }, + "location": "[parameters('location')]", + "properties": map[string]any{ + "customDnsConfigs": []any{}, + "manualPrivateLinkServiceConnections": []any{}, + "privateLinkServiceConnections": []any{ + map[string]any{ + "name": "[parameters('privateEndpointName')]", + "properties": map[string]any{ + "groupIds": []any{ + "namespace", + }, + "privateLinkServiceConnectionState": map[string]any{ + "description": "Auto-Approved", + "actionsRequired": "None", + "status": "Approved", + }, + "privateLinkServiceId": "[parameters('namespaceId')]", + }, + }, + }, + "subnet": map[string]any{ + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", + }, + }, + }, + }, + "variables": map[string]any{}, + } + deployment := armresources.Deployment{ + Properties: &armresources.DeploymentProperties{ + Template: template, + Mode: to.Ptr(armresources.DeploymentModeIncremental), + }, + } + _, err = testutil.CreateDeployment(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName, "Create_PrivateEndpoint", &deployment) + testsuite.Require().NoError(err) +} + +// Microsoft.EventHub/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} +func (testsuite *PrivateEndpointConnectionsTestSuite) TestPrivateEndpointConnections() { + var privateEndpointConnectionName string + var err error + // From step PrivateEndpointConnections_List + fmt.Println("Call operation: PrivateEndpointConnections_List") + privateEndpointConnectionsClient, err := armeventhub.NewPrivateEndpointConnectionsClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + privateEndpointConnectionsClientNewListPager := privateEndpointConnectionsClient.NewListPager(testsuite.resourceGroupName, testsuite.namespaceName, nil) + for privateEndpointConnectionsClientNewListPager.More() { + nextResult, err := privateEndpointConnectionsClientNewListPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + + privateEndpointConnectionName = *nextResult.Value[0].Name + break + } + + // From step PrivateEndpointConnections_Get + fmt.Println("Call operation: PrivateEndpointConnections_Get") + _, err = privateEndpointConnectionsClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.namespaceName, privateEndpointConnectionName, nil) + testsuite.Require().NoError(err) + + // From step PrivateLinkResources_Get + fmt.Println("Call operation: PrivateLinkResources_Get") + privateLinkResourcesClient, err := armeventhub.NewPrivateLinkResourcesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + _, err = privateLinkResourcesClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.namespaceName, nil) + testsuite.Require().NoError(err) + + // From step PrivateEndpointConnections_Delete + fmt.Println("Call operation: PrivateEndpointConnections_Delete") + privateEndpointConnectionsClientDeleteResponsePoller, err := privateEndpointConnectionsClient.BeginDelete(testsuite.ctx, testsuite.resourceGroupName, testsuite.namespaceName, privateEndpointConnectionName, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, privateEndpointConnectionsClientDeleteResponsePoller) + testsuite.Require().NoError(err) +}