public void IotSecuritySolution_Update() { var udrp = new UserDefinedResourcesProperties("where type != \"microsoft.devices/iothubs\" | where name contains \"v2\"", new[] { SubscriptionId }); var rcp = new RecommendationConfigurationProperties("IoT_OpenPorts", "Disabled"); UpdateIotSecuritySolutionData updateIotSecuritySolutionData = new UpdateIotSecuritySolutionData(null, udrp, new[] { rcp }); updateIotSecuritySolutionData.Validate(); using (var context = MockContext.Start(this.GetType())) { var securityCenterClient = GetSecurityCenterClient(context); var ret = securityCenterClient.IotSecuritySolution.Update(ResourceGroupName, SolutionName, updateIotSecuritySolutionData); ret.Validate(); } }
public override void ExecuteCmdlet() { var name = Name; var resourceGroupName = ResourceGroupName; switch (ParameterSetName) { case ParameterSetNames.ResourceGroupLevelResource: break; case ParameterSetNames.ResourceId: Name = AzureIdUtilities.GetResourceName(ResourceId); ResourceGroupName = AzureIdUtilities.GetResourceGroup(ResourceId); break; case ParameterSetNames.InputObject: Name = AzureIdUtilities.GetResourceName(InputObject.Id); ResourceGroupName = AzureIdUtilities.GetResourceGroup(InputObject.Id); RecommendationsConfiguration = RecommendationsConfiguration ?? ((List <PSRecommendationConfiguration>)InputObject.RecommendationsConfiguration).ToArray(); Tag = Tag ?? new Hashtable((IDictionary)(InputObject.Tags)); UserDefinedResource = UserDefinedResource ?? GetValidUserDefinedResources(InputObject.UserDefinedResources); break; default: throw new PSInvalidOperationException(); } UpdateIotSecuritySolutionData solutionData = new UpdateIotSecuritySolutionData(Tag?.Cast <DictionaryEntry>().ToDictionary(t => (string)t.Key, t => (string)t.Value), UserDefinedResource?.CreatePSType(), RecommendationsConfiguration?.CreatePSType()); if (ShouldProcess(Name, "Update")) { var outputSolution = SecurityCenterClient.IotSecuritySolution.UpdateWithHttpMessagesAsync(ResourceGroupName, Name, solutionData).GetAwaiter().GetResult().Body; WriteObject(outputSolution?.ConvertToPSType(), enumerateCollection: false); } }
/// <summary> /// Use this method to update existing IoT Security solution tags or user /// defined resources. To update other fields use the CreateOrUpdate method. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group within the user's subscription. The name is /// case insensitive. /// </param> /// <param name='solutionName'> /// The name of the IoT Security solution. /// </param> /// <param name='updateIotSecuritySolutionData'> /// The security solution data /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IoTSecuritySolutionModel> UpdateAsync(this IIotSecuritySolutionOperations operations, string resourceGroupName, string solutionName, UpdateIotSecuritySolutionData updateIotSecuritySolutionData, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, solutionName, updateIotSecuritySolutionData, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Use this method to update existing IoT Security solution tags or user /// defined resources. To update other fields use the CreateOrUpdate method. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group within the user's subscription. The name is /// case insensitive. /// </param> /// <param name='solutionName'> /// The name of the IoT Security solution. /// </param> /// <param name='updateIotSecuritySolutionData'> /// The security solution data /// </param> public static IoTSecuritySolutionModel Update(this IIotSecuritySolutionOperations operations, string resourceGroupName, string solutionName, UpdateIotSecuritySolutionData updateIotSecuritySolutionData) { return(operations.UpdateAsync(resourceGroupName, solutionName, updateIotSecuritySolutionData).GetAwaiter().GetResult()); }