示例#1
0
        public Task <ServerResponse> New(Action <PolicyTarget> policy, Action <PolicyCharacteristics> characteristics,
                                         Action <VirtualHostTarget> virtualHost,
                                         CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var characteristicsImpl = new PolicyCharacteristicsImpl();

            characteristics(characteristicsImpl);

            var policyTargetImpl = new PolicyTargetImpl();

            policy(policyTargetImpl);

            var virtualHostTargetImpl = new VirtualHostTargetImpl();

            virtualHost(virtualHostTargetImpl);

            LogInfo(
                string.Format("Sent request to RabbitMQ server to create a new policy '{0}' on virtual host '{1}'.",
                              policyTargetImpl.Target, virtualHostTargetImpl.Target));

            string url = string.Format("api/policies/{0}/{1}", virtualHostTargetImpl.Target.SanitizeVirtualHostName(),
                                       policyTargetImpl.Target);

            return(base.Put(url, characteristicsImpl, cancellationToken).Response <ServerResponse>(cancellationToken));
        }
示例#2
0
            public void Targeting(Action <PolicyTarget> target)
            {
                var impl = new PolicyTargetImpl();

                target(impl);

                _vhost = impl.VirtualHostName;
            }
示例#3
0
        public Task<ServerResponse> Delete(Action<PolicyTarget> policy, Action<VirtualHostTarget> virtualHost,
                                           CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var policyTargetImpl = new PolicyTargetImpl();
            policy(policyTargetImpl);

            var virtualHostTargetImpl = new VirtualHostTargetImpl();
            virtualHost(virtualHostTargetImpl);

            LogInfo(string.Format("Sent request to RabbitMQ server to delete policy '{0}' from virtual host '{1}'.",
                                  policyTargetImpl.Target, virtualHostTargetImpl.Target));

            string url = string.Format("api/policies/{0}/{1}", virtualHostTargetImpl.Target.SanitizeVirtualHostName(),
                                       policyTargetImpl.Target);

            return base.Delete(url, cancellationToken).Response<ServerResponse>(cancellationToken);
        }
示例#4
0
        public Task <ServerResponse> Delete(Action <PolicyTarget> policy, Action <VirtualHostTarget> virtualHost,
                                            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var policyTargetImpl = new PolicyTargetImpl();

            policy(policyTargetImpl);

            var virtualHostTargetImpl = new VirtualHostTargetImpl();

            virtualHost(virtualHostTargetImpl);

            LogInfo(string.Format("Sent request to RabbitMQ server to delete policy '{0}' from virtual host '{1}'.",
                                  policyTargetImpl.Target, virtualHostTargetImpl.Target));

            string url = string.Format("api/policies/{0}/{1}", virtualHostTargetImpl.Target.SanitizeVirtualHostName(),
                                       policyTargetImpl.Target);

            return(base.Delete(url, cancellationToken).Response <ServerResponse>(cancellationToken));
        }
示例#5
0
        public Task<Policy> Get(Action<PolicyTarget> policy, Action<VirtualHostTarget> virtualHost,
                                CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var policyTargetImpl = new PolicyTargetImpl();
            policy(policyTargetImpl);

            var virtualHostTargetImpl = new VirtualHostTargetImpl();
            virtualHost(virtualHostTargetImpl);

            LogInfo(
                string.Format(
                    "Sent request to RabbitMQ server to return policy information pertaining to policy '{0}' belonging to virtual host '{1}'.",
                    policyTargetImpl.Target, virtualHostTargetImpl.Target));

            string url = string.Format("api/policies/{0}/{1}", virtualHostTargetImpl.Target.SanitizeVirtualHostName(),
                                       policyTargetImpl.Target);

            return base.Get(url, cancellationToken).As<Policy>(cancellationToken);
        }
示例#6
0
        public Task <Policy> Get(Action <PolicyTarget> policy, Action <VirtualHostTarget> virtualHost,
                                 CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var policyTargetImpl = new PolicyTargetImpl();

            policy(policyTargetImpl);

            var virtualHostTargetImpl = new VirtualHostTargetImpl();

            virtualHost(virtualHostTargetImpl);

            LogInfo(
                string.Format(
                    "Sent request to RabbitMQ server to return policy information pertaining to policy '{0}' belonging to virtual host '{1}'.",
                    policyTargetImpl.Target, virtualHostTargetImpl.Target));

            string url = string.Format("api/policies/{0}/{1}", virtualHostTargetImpl.Target.SanitizeVirtualHostName(),
                                       policyTargetImpl.Target);

            return(base.Get(url, cancellationToken).As <Policy>(cancellationToken));
        }
示例#7
0
        public Task<ServerResponse> New(Action<PolicyTarget> policy, Action<PolicyCharacteristics> characteristics,
                                        Action<VirtualHostTarget> virtualHost,
                                        CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var characteristicsImpl = new PolicyCharacteristicsImpl();
            characteristics(characteristicsImpl);

            var policyTargetImpl = new PolicyTargetImpl();
            policy(policyTargetImpl);

            var virtualHostTargetImpl = new VirtualHostTargetImpl();
            virtualHost(virtualHostTargetImpl);

            LogInfo(
                string.Format("Sent request to RabbitMQ server to create a new policy '{0}' on virtual host '{1}'.",
                              policyTargetImpl.Target, virtualHostTargetImpl.Target));

            string url = string.Format("api/policies/{0}/{1}", virtualHostTargetImpl.Target.SanitizeVirtualHostName(),
                                       policyTargetImpl.Target);

            return base.Put(url, characteristicsImpl, cancellationToken).Response<ServerResponse>(cancellationToken);
        }