/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (PolicyName != null) { hashCode = hashCode * 59 + PolicyName.GetHashCode(); } if (Scopes != null) { hashCode = hashCode * 59 + Scopes.GetHashCode(); } if (Actions != null) { hashCode = hashCode * 59 + Actions.GetHashCode(); } if (CreateDate != null) { hashCode = hashCode * 59 + CreateDate.GetHashCode(); } return(hashCode); } }
private void UpdatePolicy(object param) { try { if (SelectedPolicy == null) throw new Exception("Политика не выбрана"); if (string.IsNullOrEmpty(PolicyName.Trim()) || SelectedPlatform == null) throw new Exception("Не заполнены обязательные поля"); using (var policyService = _ppsClientViewModel.ServiceProxy.GetPpsChannelFactory<IPolicyService>()) { var channel = policyService.CreateChannel(); var policyName = PolicyName; var result = channel.UpdatePolicy(SelectedPolicy, new PolicyDataContract { PolicyId = SelectedPolicy.PolicyId, PlatformId = SelectedPlatform.PlatformId, PolicyInstruction = PolicyInstruction.Trim(), PolicyName = PolicyName.Trim(), PolicyDefaultParam = PolicyDefaultParam.Trim() }); if (!result.BoolRes || !string.IsNullOrEmpty(result.ErrorRes)) throw new Exception(result.ErrorRes); _ppsClientViewModel.UpdatePolicyCollection(); _ppsClientViewModel.AddEvent(EventConstants.EVENT_UPD_POLICY, policyName); } } catch (Exception ex) { _ppsClientViewModel.WriteLogMessage("Не удалось изменить политику - " + ex.Message); } }
public async stt::Task CreatePolicyResourceNames3Async() { moq::Mock <OrgPolicy.OrgPolicyClient> mockGrpcClient = new moq::Mock <OrgPolicy.OrgPolicyClient>(moq::MockBehavior.Strict); CreatePolicyRequest request = new CreatePolicyRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), Policy = new Policy(), }; Policy expectedResponse = new Policy { PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"), Spec = new PolicySpec(), Alternate = new AlternatePolicySpec(), }; mockGrpcClient.Setup(x => x.CreatePolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Policy>(stt::Task.FromResult(expectedResponse), null, null, null, null)); OrgPolicyClient client = new OrgPolicyClientImpl(mockGrpcClient.Object, null); Policy responseCallSettings = await client.CreatePolicyAsync(request.ParentAsOrganizationName, request.Policy, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Policy responseCancellationToken = await client.CreatePolicyAsync(request.ParentAsOrganizationName, request.Policy, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task GetSystemPolicyRequestObjectAsync() { moq::Mock <SystemPolicyV1Beta1.SystemPolicyV1Beta1Client> mockGrpcClient = new moq::Mock <SystemPolicyV1Beta1.SystemPolicyV1Beta1Client>(moq::MockBehavior.Strict); GetSystemPolicyRequest request = new GetSystemPolicyRequest { PolicyName = PolicyName.FromProject("[PROJECT]"), }; Policy expectedResponse = new Policy { PolicyName = PolicyName.FromProject("[PROJECT]"), AdmissionWhitelistPatterns = { new AdmissionWhitelistPattern(), }, ClusterAdmissionRules = { { "key8a0b6e3c", new AdmissionRule() }, }, DefaultAdmissionRule = new AdmissionRule(), UpdateTime = new wkt::Timestamp(), Description = "description2cf9da67", GlobalPolicyEvaluationMode = Policy.Types.GlobalPolicyEvaluationMode.Disable, KubernetesServiceAccountAdmissionRules = { { "key8a0b6e3c", new AdmissionRule() }, }, IstioServiceIdentityAdmissionRules = { { "key8a0b6e3c", new AdmissionRule() }, }, KubernetesNamespaceAdmissionRules = { { "key8a0b6e3c", new AdmissionRule() }, }, }; mockGrpcClient.Setup(x => x.GetSystemPolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Policy>(stt::Task.FromResult(expectedResponse), null, null, null, null)); SystemPolicyV1Beta1Client client = new SystemPolicyV1Beta1ClientImpl(mockGrpcClient.Object, null); Policy responseCallSettings = await client.GetSystemPolicyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Policy responseCancellationToken = await client.GetSystemPolicyAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetPolicy</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetPolicyResourceNames() { // Create client BinauthzManagementServiceV1Beta1Client binauthzManagementServiceV1Beta1Client = BinauthzManagementServiceV1Beta1Client.Create(); // Initialize request argument(s) PolicyName name = PolicyName.FromProject("[PROJECT]"); // Make the request Policy response = binauthzManagementServiceV1Beta1Client.GetPolicy(name); }
public MicroPipelineComponentDummyTen() { Encoding = new UTF8Encoding(true); Index = 10; Modes = XmlTranslationModes.AbsorbXmlDeclaration | XmlTranslationModes.TranslateAttributeNamespace; Name = "DummyTen"; Plugin = typeof(DummyContextPropertyExtractorComponent); Policy = new PolicyName("DummyPolicy", 1, 1); }
/// <summary>Snippet for GetPolicyAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetPolicyResourceNamesAsync() { // Create client BinauthzManagementServiceV1Beta1Client binauthzManagementServiceV1Beta1Client = await BinauthzManagementServiceV1Beta1Client.CreateAsync(); // Initialize request argument(s) PolicyName name = PolicyName.FromProject("[PROJECT]"); // Make the request Policy response = await binauthzManagementServiceV1Beta1Client.GetPolicyAsync(name); }
public void GetSystemPolicyRequestObject() { moq::Mock <SystemPolicyV1Beta1.SystemPolicyV1Beta1Client> mockGrpcClient = new moq::Mock <SystemPolicyV1Beta1.SystemPolicyV1Beta1Client>(moq::MockBehavior.Strict); GetSystemPolicyRequest request = new GetSystemPolicyRequest { PolicyName = PolicyName.FromProject("[PROJECT]"), }; Policy expectedResponse = new Policy { PolicyName = PolicyName.FromProject("[PROJECT]"), AdmissionWhitelistPatterns = { new AdmissionWhitelistPattern(), }, ClusterAdmissionRules = { { "key8a0b6e3c", new AdmissionRule() }, }, DefaultAdmissionRule = new AdmissionRule(), UpdateTime = new wkt::Timestamp(), Description = "description2cf9da67", GlobalPolicyEvaluationMode = Policy.Types.GlobalPolicyEvaluationMode.Disable, KubernetesServiceAccountAdmissionRules = { { "key8a0b6e3c", new AdmissionRule() }, }, IstioServiceIdentityAdmissionRules = { { "key8a0b6e3c", new AdmissionRule() }, }, KubernetesNamespaceAdmissionRules = { { "key8a0b6e3c", new AdmissionRule() }, }, }; mockGrpcClient.Setup(x => x.GetSystemPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); SystemPolicyV1Beta1Client client = new SystemPolicyV1Beta1ClientImpl(mockGrpcClient.Object, null); Policy response = client.GetSystemPolicy(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetSystemPolicy</summary> public void GetSystemPolicyResourceNames() { // Snippet: GetSystemPolicy(PolicyName, CallSettings) // Create client SystemPolicyV1Beta1Client systemPolicyV1Beta1Client = SystemPolicyV1Beta1Client.Create(); // Initialize request argument(s) PolicyName name = PolicyName.FromProject("[PROJECT]"); // Make the request Policy response = systemPolicyV1Beta1Client.GetSystemPolicy(name); // End snippet }
/// <summary>Snippet for GetPolicy</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetPolicyRequestObject() { // Create client BinauthzManagementServiceV1Beta1Client binauthzManagementServiceV1Beta1Client = BinauthzManagementServiceV1Beta1Client.Create(); // Initialize request argument(s) GetPolicyRequest request = new GetPolicyRequest { PolicyName = PolicyName.FromProject("[PROJECT]"), }; // Make the request Policy response = binauthzManagementServiceV1Beta1Client.GetPolicy(request); }
/// <summary>Snippet for GetPolicyAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetPolicyRequestObjectAsync() { // Create client BinauthzManagementServiceV1Beta1Client binauthzManagementServiceV1Beta1Client = await BinauthzManagementServiceV1Beta1Client.CreateAsync(); // Initialize request argument(s) GetPolicyRequest request = new GetPolicyRequest { PolicyName = PolicyName.FromProject("[PROJECT]"), }; // Make the request Policy response = await binauthzManagementServiceV1Beta1Client.GetPolicyAsync(request); }
/// <summary>Snippet for GetSystemPolicyAsync</summary> public async Task GetSystemPolicyResourceNamesAsync() { // Snippet: GetSystemPolicyAsync(PolicyName, CallSettings) // Additional: GetSystemPolicyAsync(PolicyName, CancellationToken) // Create client SystemPolicyV1Beta1Client systemPolicyV1Beta1Client = await SystemPolicyV1Beta1Client.CreateAsync(); // Initialize request argument(s) PolicyName name = PolicyName.FromProject("[PROJECT]"); // Make the request Policy response = await systemPolicyV1Beta1Client.GetSystemPolicyAsync(name); // End snippet }
/// <summary>Snippet for GetSystemPolicy</summary> public void GetSystemPolicyRequestObject() { // Snippet: GetSystemPolicy(GetSystemPolicyRequest, CallSettings) // Create client SystemPolicyV1Beta1Client systemPolicyV1Beta1Client = SystemPolicyV1Beta1Client.Create(); // Initialize request argument(s) GetSystemPolicyRequest request = new GetSystemPolicyRequest { PolicyName = PolicyName.FromProject("[PROJECT]"), }; // Make the request Policy response = systemPolicyV1Beta1Client.GetSystemPolicy(request); // End snippet }
public void DeletePolicyResourceNames() { moq::Mock <OrgPolicy.OrgPolicyClient> mockGrpcClient = new moq::Mock <OrgPolicy.OrgPolicyClient>(moq::MockBehavior.Strict); DeletePolicyRequest request = new DeletePolicyRequest { PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeletePolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); OrgPolicyClient client = new OrgPolicyClientImpl(mockGrpcClient.Object, null); client.DeletePolicy(request.PolicyName); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetSystemPolicyAsync</summary> public async Task GetSystemPolicyRequestObjectAsync() { // Snippet: GetSystemPolicyAsync(GetSystemPolicyRequest, CallSettings) // Additional: GetSystemPolicyAsync(GetSystemPolicyRequest, CancellationToken) // Create client SystemPolicyV1Beta1Client systemPolicyV1Beta1Client = await SystemPolicyV1Beta1Client.CreateAsync(); // Initialize request argument(s) GetSystemPolicyRequest request = new GetSystemPolicyRequest { PolicyName = PolicyName.FromProject("[PROJECT]"), }; // Make the request Policy response = await systemPolicyV1Beta1Client.GetSystemPolicyAsync(request); // End snippet }
public async stt::Task DeletePolicyResourceNamesAsync() { moq::Mock <OrgPolicy.OrgPolicyClient> mockGrpcClient = new moq::Mock <OrgPolicy.OrgPolicyClient>(moq::MockBehavior.Strict); DeletePolicyRequest request = new DeletePolicyRequest { PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeletePolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); OrgPolicyClient client = new OrgPolicyClientImpl(mockGrpcClient.Object, null); await client.DeletePolicyAsync(request.PolicyName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeletePolicyAsync(request.PolicyName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
public static void HandleException(ExceptionBE log, Exception ex, bool propagate = true) { // register in database ExceptionBL errorModule = new ExceptionBL(); log.Message = GetMessage(ex); log.Type = PolicyName.ResolvePolicy(log.Class); errorModule.Create(log); if (log.Type == PolicyName.Business || log.Type == PolicyName.Data) { if (propagate) { throw ex; } } }
public void GetPolicy() { moq::Mock <OrgPolicy.OrgPolicyClient> mockGrpcClient = new moq::Mock <OrgPolicy.OrgPolicyClient>(moq::MockBehavior.Strict); GetPolicyRequest request = new GetPolicyRequest { PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"), }; Policy expectedResponse = new Policy { PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"), Spec = new PolicySpec(), Alternate = new AlternatePolicySpec(), }; mockGrpcClient.Setup(x => x.GetPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); OrgPolicyClient client = new OrgPolicyClientImpl(mockGrpcClient.Object, null); Policy response = client.GetPolicy(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void CreatePolicyResourceNames3() { moq::Mock <OrgPolicy.OrgPolicyClient> mockGrpcClient = new moq::Mock <OrgPolicy.OrgPolicyClient>(moq::MockBehavior.Strict); CreatePolicyRequest request = new CreatePolicyRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), Policy = new Policy(), }; Policy expectedResponse = new Policy { PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"), Spec = new PolicySpec(), Alternate = new AlternatePolicySpec(), }; mockGrpcClient.Setup(x => x.CreatePolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); OrgPolicyClient client = new OrgPolicyClientImpl(mockGrpcClient.Object, null); Policy response = client.CreatePolicy(request.ParentAsOrganizationName, request.Policy); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Returns true if Policy instances are equal /// </summary> /// <param name="other">Instance of Policy to be compared</param> /// <returns>Boolean</returns> public bool Equals(Policy other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( PolicyName == other.PolicyName || PolicyName != null && PolicyName.Equals(other.PolicyName) ) && ( Scopes == other.Scopes || Scopes != null && Scopes.SequenceEqual(other.Scopes) ) && ( Actions == other.Actions || Actions != null && Actions.SequenceEqual(other.Actions) ) && ( CreateDate == other.CreateDate || CreateDate != null && CreateDate.Equals(other.CreateDate) )); }
public IBaseMessage Execute(IPipelineContext pipelineContext, IBaseMessage message) { if (PolicyName == null) { return(message); } if (ExecutionMode == PluginExecutionMode.Deferred) { if (_logger.IsDebugEnabled) { _logger.DebugFormat("Scheduling policy '{0}' for deferred execution.", PolicyName.ToString()); } message.BodyPart.WrapOriginalDataStream( originalStream => { var substitutionStream = new EventingReadStream(originalStream); substitutionStream.AfterLastReadEvent += (src, args) => { if (_logger.IsDebugEnabled) { _logger.DebugFormat("Executing policy '{0}' that was scheduled for deferred execution.", PolicyName.ToString()); } Policy.Execute(PolicyName, new Context(message.Context)); }; return(substitutionStream); }, pipelineContext.ResourceTracker); } else { if (_logger.IsDebugEnabled) { _logger.DebugFormat("Executing policy '{0}' that is scheduled for immediate execution.", PolicyName.ToString()); } Policy.Execute(PolicyName, new Context(message.Context)); } return(message); }
/// <summary> /// Loads configuration properties for the component /// </summary> /// <param name="propertyBag">Configuration property bag</param> protected override void Load(IPropertyBag propertyBag) { propertyBag.ReadProperty <PluginExecutionMode>("ExecutionMode", value => ExecutionMode = value); propertyBag.ReadProperty("Policy", value => Policy = PolicyName.Parse(value)); }