public async Task <Response <FirewallPolicy> > GetAsync(string resourceGroupName, string firewallPolicyName, string expand = null, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (firewallPolicyName == null) { throw new ArgumentNullException(nameof(firewallPolicyName)); } using var message = CreateGetRequest(resourceGroupName, firewallPolicyName, expand); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { FirewallPolicy value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = FirewallPolicy.DeserializeFirewallPolicy(document.RootElement); } return(Response.FromValue(value, message.Response)); }
public PSAzureFirewallPolicy ToPsAzureFirewallPolicy(FirewallPolicy firewall) { var azureFirewallPolicy = NetworkResourceManagerProfile.Mapper.Map <PSAzureFirewallPolicy>(firewall); azureFirewallPolicy.Tag = TagsConversionHelper.CreateTagHashtable(firewall.Tags); return(azureFirewallPolicy); }
public async stt::Task GetRequestObjectAsync() { moq::Mock <FirewallPolicies.FirewallPoliciesClient> mockGrpcClient = new moq::Mock <FirewallPolicies.FirewallPoliciesClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOrganizationOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetFirewallPolicyRequest request = new GetFirewallPolicyRequest { FirewallPolicy = "firewall_policy1f9c9144", }; FirewallPolicy expectedResponse = new FirewallPolicy { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", DisplayName = "display_name137f65c2", CreationTimestamp = "creation_timestamp235e59a1", SelfLinkWithId = "self_link_with_id6d1e3896", Parent = "parent7858e4d0", Rules = { new FirewallPolicyRule(), }, Fingerprint = "fingerprint009e6052", RuleTupleCount = -1393850828, Description = "description2cf9da67", SelfLink = "self_link7e87f12d", ShortName = "short_namec7ba9846", Associations = { new FirewallPolicyAssociation(), }, }; mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <FirewallPolicy>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FirewallPoliciesClient client = new FirewallPoliciesClientImpl(mockGrpcClient.Object, null); FirewallPolicy responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); FirewallPolicy responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary> /// Creates or updates the specified Firewall Policy. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='firewallPolicyName'> /// The name of the Firewall Policy. /// </param> /// <param name='parameters'> /// Parameters supplied to the create or update Firewall Policy operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <FirewallPolicy> BeginCreateOrUpdateAsync(this IFirewallPoliciesOperations operations, string resourceGroupName, string firewallPolicyName, FirewallPolicy parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, firewallPolicyName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates the specified Firewall Policy. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='firewallPolicyName'> /// The name of the Firewall Policy. /// </param> /// <param name='parameters'> /// Parameters supplied to the create or update Firewall Policy operation. /// </param> public static FirewallPolicy BeginCreateOrUpdate(this IFirewallPoliciesOperations operations, string resourceGroupName, string firewallPolicyName, FirewallPolicy parameters) { return(operations.BeginCreateOrUpdateAsync(resourceGroupName, firewallPolicyName, parameters).GetAwaiter().GetResult()); }
public virtual FirewallPoliciesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string firewallPolicyName, FirewallPolicy parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (firewallPolicyName == null) { throw new ArgumentNullException(nameof(firewallPolicyName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("FirewallPoliciesClient.StartCreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, firewallPolicyName, parameters, cancellationToken); return(new FirewallPoliciesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, firewallPolicyName, parameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }
public static void EnableFirewall(bool enable) { FirewallPolicy.EnableRuleGroup((int)NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_ALL, "Argon", enable); }
public static bool GetEnabledState() { return(FirewallPolicy.IsRuleGroupEnabled((int)NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_ALL, "Argon")); }