public PSRelayNamespaceAttributes UpdateNamespace(string resourceGroupName, string namespaceName, RelayNamespaceAttirbutesUpdateParameter relaynamespace) { var parameter = new RelayUpdateParameters(); if (relaynamespace.Tags != null && relaynamespace.Tags.Count() > 0) { parameter.Tags = new Dictionary <string, string>(relaynamespace.Tags); } var response = Client.Namespaces.Update(resourceGroupName, namespaceName, parameter); return(new PSRelayNamespaceAttributes(response)); }
/// <summary> /// Creates or updates a namespace. Once created, this namespace's resource /// manifest is immutable. This operation is idempotent. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the Resource group within the Azure subscription. /// </param> /// <param name='namespaceName'> /// The namespace name /// </param> /// <param name='parameters'> /// Parameters for updating a namespace resource. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <RelayNamespace> UpdateAsync(this INamespacesOperations operations, string resourceGroupName, string namespaceName, RelayUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, namespaceName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public RelayNamespaceAttirbutesUpdateParameter(RelayUpdateParameters relaynamespaceupdateparameter) { Tags = relaynamespaceupdateparameter.Tags; }
/// <summary> /// Creates or updates a namespace. Once created, this namespace's resource /// manifest is immutable. This operation is idempotent. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the Resource group within the Azure subscription. /// </param> /// <param name='namespaceName'> /// The namespace name /// </param> /// <param name='parameters'> /// Parameters for updating a namespace resource. /// </param> public static RelayNamespace Update(this INamespacesOperations operations, string resourceGroupName, string namespaceName, RelayUpdateParameters parameters) { return(operations.UpdateAsync(resourceGroupName, namespaceName, parameters).GetAwaiter().GetResult()); }
public void NamespaceCreateGetUpdateDelete() { using (MockContext context = MockContext.Start(this.GetType())) { InitializeClients(context); var location = this.ResourceManagementClient.GetLocationFromProvider(); var resourceGroup = this.ResourceManagementClient.TryGetResourceGroup(location); if (string.IsNullOrWhiteSpace(resourceGroup)) { resourceGroup = TestUtilities.GenerateName(RelayManagementHelper.ResourceGroupPrefix); this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup); } // Create Namespace var namespaceName = TestUtilities.GenerateName(RelayManagementHelper.NamespacePrefix); // CheckNameAvailability var checkNameAvailabilityResponse = this.RelayManagementClient.Namespaces.CheckNameAvailabilityMethod(new CheckNameAvailability { Name = namespaceName }); Assert.True(checkNameAvailabilityResponse.NameAvailable); var createNamespaceResponse = this.RelayManagementClient.Namespaces.CreateOrUpdate(resourceGroup, namespaceName, new RelayNamespace() { Location = location, Tags = new Dictionary <string, string>() { { "tag1", "value1" }, { "tag2", "value2" } } }); Assert.NotNull(createNamespaceResponse); Assert.Equal(createNamespaceResponse.Name, namespaceName); Assert.Equal(2, createNamespaceResponse.Tags.Count); Assert.Equal("Microsoft.Relay/Namespaces", createNamespaceResponse.Type); TestUtilities.Wait(TimeSpan.FromSeconds(5)); // Get the created namespace var getNamespaceResponse = RelayManagementClient.Namespaces.Get(resourceGroup, namespaceName); if (string.Compare(getNamespaceResponse.ProvisioningState.ToString(), "Succeeded", true) != 0) { TestUtilities.Wait(TimeSpan.FromSeconds(5)); } getNamespaceResponse = RelayManagementClient.Namespaces.Get(resourceGroup, namespaceName); Assert.NotNull(getNamespaceResponse); Assert.Equal("Succeeded", getNamespaceResponse.ProvisioningState.ToString(), StringComparer.CurrentCultureIgnoreCase); Assert.Equal(location, getNamespaceResponse.Location, StringComparer.CurrentCultureIgnoreCase); // Get all namespaces created within a resourceGroup var getAllNamespacesResponse = RelayManagementClient.Namespaces.ListByResourceGroup(resourceGroup); Assert.NotNull(getAllNamespacesResponse); Assert.True(getAllNamespacesResponse.Count() >= 1); Assert.Contains(getAllNamespacesResponse, ns => ns.Name == namespaceName); Assert.True(getAllNamespacesResponse.All(ns => ns.Id.Contains(resourceGroup))); // Get all namespaces created within the subscription irrespective of the resourceGroup getAllNamespacesResponse = RelayManagementClient.Namespaces.List(); Assert.NotNull(getAllNamespacesResponse); Assert.True(getAllNamespacesResponse.Count() >= 1); Assert.Contains(getAllNamespacesResponse, ns => ns.Name == namespaceName); // Update namespace tags var updateNamespaceParameter = new RelayUpdateParameters() { Tags = new Dictionary <string, string>() { { "tag3", "value3" }, { "tag4", "value4" }, { "tag5", "value5" }, { "tag6", "value6" } } }; var updateNamespaceResponse = RelayManagementClient.Namespaces.Update(resourceGroup, namespaceName, updateNamespaceParameter); TestUtilities.Wait(TimeSpan.FromSeconds(5)); // Get the updated namespace getNamespaceResponse = RelayManagementClient.Namespaces.Get(resourceGroup, namespaceName); Assert.NotNull(getNamespaceResponse); Assert.Equal(location, getNamespaceResponse.Location, StringComparer.CurrentCultureIgnoreCase); Assert.Equal(namespaceName, getNamespaceResponse.Name); Assert.Equal(4, getNamespaceResponse.Tags.Count); foreach (var tag in updateNamespaceParameter.Tags) { Assert.Contains(getNamespaceResponse.Tags, t => t.Key.Equals(tag.Key)); Assert.Contains(getNamespaceResponse.Tags, t => t.Value.Equals(tag.Value)); } try { // Delete namespace RelayManagementClient.Namespaces.Delete(resourceGroup, namespaceName); } catch (Exception ex) { Assert.Contains("NotFound", ex.Message); } } }