/// <summary> /// Patches specific property. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.ApiManagement.IPropertiesOperations. /// </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='propId'> /// Required. Identifier of the property. /// </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 IPropertiesOperations operations, string resourceGroupName, string serviceName, string propId, PropertyUpdateParameters parameters, string etag) { return(operations.UpdateAsync(resourceGroupName, serviceName, propId, parameters, etag, CancellationToken.None)); }
/// <summary> /// Patches specific property. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.ApiManagement.IPropertiesOperations. /// </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='propId'> /// Required. Identifier of the property. /// </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 IPropertiesOperations operations, string resourceGroupName, string serviceName, string propId, PropertyUpdateParameters parameters, string etag) { return(Task.Factory.StartNew((object s) => { return ((IPropertiesOperations)s).UpdateAsync(resourceGroupName, serviceName, propId, parameters, etag); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Updates the specific property. /// </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='propId'> /// Identifier of the property. /// </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 IPropertyOperations operations, string resourceGroupName, string serviceName, string propId, PropertyUpdateParameters parameters, string ifMatch, CancellationToken cancellationToken = default(CancellationToken)) { (await operations.UpdateWithHttpMessagesAsync(resourceGroupName, serviceName, propId, parameters, ifMatch, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
public async Task CreateListUpdateDelete() { Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback"); using (MockContext context = MockContext.Start(this.GetType())) { var testBase = new ApiManagementTestBase(context); testBase.TryCreateApiManagementService(); string propertyId = TestUtilities.GenerateName("newproperty"); string secretPropertyId = TestUtilities.GenerateName("secretproperty"); try { string propertyDisplayName = TestUtilities.GenerateName("propertydisplay"); string propertyValue = TestUtilities.GenerateName("propertyValue"); var createParameters = new PropertyContract(propertyDisplayName, propertyValue); // create a property var propertyResponse = testBase.client.Property.CreateOrUpdate( testBase.rgName, testBase.serviceName, propertyId, createParameters); ValidateProperty(propertyResponse, testBase, propertyId, propertyDisplayName, propertyValue, false); // get the property var getResponse = testBase.client.Property.Get( testBase.rgName, testBase.serviceName, propertyId); ValidateProperty(propertyResponse, testBase, propertyId, propertyDisplayName, propertyValue, false); // create secret property string secretPropertyDisplayName = TestUtilities.GenerateName("secretPropertydisplay"); string secretPropertyValue = TestUtilities.GenerateName("secretPropertyValue"); List <string> tags = new List <string> { "secret" }; var secretCreateParameters = new PropertyContract(secretPropertyDisplayName, secretPropertyValue) { Secret = true, Tags = tags }; var secretPropertyResponse = testBase.client.Property.CreateOrUpdate( testBase.rgName, testBase.serviceName, secretPropertyId, secretCreateParameters); ValidateProperty(secretPropertyResponse, testBase, secretPropertyId, secretPropertyDisplayName, secretPropertyValue, true); // list the properties var listResponse = testBase.client.Property.ListByService(testBase.rgName, testBase.serviceName, null); Assert.NotNull(listResponse); Assert.Equal(2, listResponse.Count()); // delete a property testBase.client.Property.Delete( testBase.rgName, testBase.serviceName, propertyId, "*"); Assert.Throws <ErrorResponseException>(() => testBase.client.Property.Get(testBase.rgName, testBase.serviceName, propertyId)); // get the property etag var propertyTag = await testBase.client.Property.GetEntityTagAsync( testBase.rgName, testBase.serviceName, secretPropertyId); Assert.NotNull(propertyTag); Assert.NotNull(propertyTag.ETag); // patch the secret property var updateProperty = new PropertyUpdateParameters() { Secret = false }; testBase.client.Property.Update( testBase.rgName, testBase.serviceName, secretPropertyId, updateProperty, propertyTag.ETag); // check it is patched var secretResponse = await testBase.client.Property.GetAsync( testBase.rgName, testBase.serviceName, secretPropertyId); ValidateProperty( secretResponse, testBase, secretPropertyId, secretPropertyDisplayName, secretPropertyValue, false); // delete this property testBase.client.Property.Delete( testBase.rgName, testBase.serviceName, secretPropertyId, "*"); Assert.Throws <ErrorResponseException>(() => testBase.client.Property.Get(testBase.rgName, testBase.serviceName, secretPropertyId)); } finally { testBase.client.Property.Delete(testBase.rgName, testBase.serviceName, propertyId, "*"); testBase.client.Property.Delete(testBase.rgName, testBase.serviceName, secretPropertyId, "*"); } } }
/// <summary> /// Updates the specific property. /// </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='propId'> /// Identifier of the property. /// </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 void Update(this IPropertyOperations operations, string resourceGroupName, string serviceName, string propId, PropertyUpdateParameters parameters, string ifMatch) { operations.UpdateAsync(resourceGroupName, serviceName, propId, parameters, ifMatch).GetAwaiter().GetResult(); }