/// <summary>
 /// Updates the details of the group specified by its identifier.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='serviceName'>
 /// The name of the API Management service.
 /// </param>
 /// <param name='groupId'>
 /// Group identifier. Must be unique in the current API Management service
 /// instance.
 /// </param>
 /// <param name='parameters'>
 /// Update parameters.
 /// </param>
 /// <param name='ifMatch'>
 /// ETag of the Entity. ETag should match the current entity state from the
 /// header response of the GET request or it should be * for unconditional
 /// update.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <GroupContract> UpdateAsync(this IGroupOperations operations, string resourceGroupName, string serviceName, string groupId, GroupUpdateParameters parameters, string ifMatch, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, serviceName, groupId, parameters, ifMatch, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Updates the details of the group specified by its identifier.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='serviceName'>
 /// The name of the API Management service.
 /// </param>
 /// <param name='groupId'>
 /// Group identifier. Must be unique in the current API Management service
 /// instance.
 /// </param>
 /// <param name='parameters'>
 /// Update parameters.
 /// </param>
 /// <param name='ifMatch'>
 /// ETag of the Entity. ETag should match the current entity state from the
 /// header response of the GET request or it should be * for unconditional
 /// update.
 /// </param>
 public static GroupContract Update(this IGroupOperations operations, string resourceGroupName, string serviceName, string groupId, GroupUpdateParameters parameters, string ifMatch)
 {
     return(operations.UpdateAsync(resourceGroupName, serviceName, groupId, parameters, ifMatch).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Patches specific group.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.ApiManagement.IGroupsOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='serviceName'>
 /// Required. The name of the Api Management service.
 /// </param>
 /// <param name='gid'>
 /// Required. Identifier of the group.
 /// </param>
 /// <param name='parameters'>
 /// Required. Update parameters.
 /// </param>
 /// <param name='etag'>
 /// Required. ETag.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task <AzureOperationResponse> UpdateAsync(this IGroupsOperations operations, string resourceGroupName, string serviceName, string gid, GroupUpdateParameters parameters, string etag)
 {
     return(operations.UpdateAsync(resourceGroupName, serviceName, gid, parameters, etag, CancellationToken.None));
 }
 /// <summary>
 /// Patches specific group.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.ApiManagement.IGroupsOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='serviceName'>
 /// Required. The name of the Api Management service.
 /// </param>
 /// <param name='gid'>
 /// Required. Identifier of the group.
 /// </param>
 /// <param name='parameters'>
 /// Required. Update parameters.
 /// </param>
 /// <param name='etag'>
 /// Required. ETag.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static AzureOperationResponse Update(this IGroupsOperations operations, string resourceGroupName, string serviceName, string gid, GroupUpdateParameters parameters, string etag)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IGroupsOperations)s).UpdateAsync(resourceGroupName, serviceName, gid, parameters, etag);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemple #5
0
        public async Task CreateListUpdateDelete()
        {
            Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback");
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                var testBase = new ApiManagementTestBase(context);
                testBase.TryCreateApiManagementService();

                // list all groups
                var groupsList = testBase.client.Group.ListByService(
                    testBase.rgName,
                    testBase.serviceName,
                    null);

                Assert.NotEmpty(groupsList);
                Assert.Equal(3, groupsList.GetEnumerator().ToIEnumerable().Count());
                Assert.Null(groupsList.NextPageLink);

                // list by paging using ODATA query
                groupsList = testBase.client.Group.ListByService(
                    testBase.rgName,
                    testBase.serviceName,
                    new Microsoft.Rest.Azure.OData.ODataQuery <GroupContract>()
                {
                    Top = 1
                });

                Assert.NotNull(groupsList);
                Assert.Single(groupsList);
                Assert.NotNull(groupsList.NextPageLink);

                // create a new group
                var newGroupId = TestUtilities.GenerateName("sdkGroupId");
                try
                {
                    var newGroupDisplayName = TestUtilities.GenerateName("sdkGroup");
                    var parameters          = new GroupCreateParameters()
                    {
                        DisplayName = newGroupDisplayName,
                        Description = "Group created from Sdk client"
                    };

                    var groupContract = testBase.client.Group.CreateOrUpdate(
                        testBase.rgName,
                        testBase.serviceName,
                        newGroupId,
                        parameters);
                    Assert.NotNull(groupContract);
                    Assert.Equal(newGroupDisplayName, groupContract.DisplayName);
                    Assert.False(groupContract.BuiltIn);
                    Assert.NotNull(groupContract.Description);
                    Assert.Equal(GroupType.Custom, groupContract.GroupContractType);

                    // get the group tag
                    var groupTag = await testBase.client.Group.GetEntityTagAsync(
                        testBase.rgName,
                        testBase.serviceName,
                        newGroupId);

                    Assert.NotNull(groupTag);
                    Assert.NotNull(groupTag.ETag);

                    // update the group
                    var updateParameters = new GroupUpdateParameters()
                    {
                        Description = "Updating the description of the Sdk"
                    };

                    testBase.client.Group.Update(
                        testBase.rgName,
                        testBase.serviceName,
                        newGroupId,
                        updateParameters,
                        groupTag.ETag);

                    // get the updatedGroup
                    var updatedResponse = await testBase.client.Group.GetAsync(
                        testBase.rgName,
                        testBase.serviceName,
                        newGroupId);

                    Assert.NotNull(updatedResponse);
                    Assert.Equal(newGroupDisplayName, updatedResponse.DisplayName);
                    Assert.False(updatedResponse.BuiltIn);
                    Assert.NotNull(updatedResponse.Description);
                    Assert.Equal(updateParameters.Description, updatedResponse.Description);
                    Assert.Equal(GroupType.Custom, updatedResponse.GroupContractType);

                    groupTag = await testBase.client.Group.GetEntityTagAsync(
                        testBase.rgName,
                        testBase.serviceName,
                        newGroupId);

                    Assert.NotNull(groupTag);
                    Assert.NotNull(groupTag.ETag);

                    // delete the group
                    testBase.client.Group.Delete(
                        testBase.rgName,
                        testBase.serviceName,
                        newGroupId,
                        groupTag.ETag);

                    Assert.Throws <ErrorResponseException>(() =>
                    {
                        testBase.client.Group.Get(
                            testBase.rgName,
                            testBase.serviceName,
                            newGroupId);
                    });
                }
                finally
                {
                    testBase.client.Group.Delete(testBase.rgName, testBase.serviceName, newGroupId, "*");
                }
            }
        }
 /// <summary>
 /// Updates the details of the group specified by its identifier.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='serviceName'>
 /// The name of the API Management service.
 /// </param>
 /// <param name='groupId'>
 /// Group identifier. Must be unique in the current API Management service
 /// instance.
 /// </param>
 /// <param name='parameters'>
 /// Update parameters.
 /// </param>
 /// <param name='ifMatch'>
 /// ETag of the Entity. ETag should match the current entity state from the
 /// header response of the GET request or it should be * for unconditional
 /// update.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task UpdateAsync(this IGroupOperations operations, string resourceGroupName, string serviceName, string groupId, GroupUpdateParameters parameters, string ifMatch, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.UpdateWithHttpMessagesAsync(resourceGroupName, serviceName, groupId, parameters, ifMatch, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }