public Task <ServerResponse> Set(Action <UserTarget> user, Action <UserPermissionsBehavior> behavior,
                                         Action <VirtualHostTarget> virtualHost,
                                         CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var argsImpl = new UserPermissionsBehaviorImpl();

            behavior(argsImpl);

            var virtualHostTargetImpl = new VirtualHostTargetImpl();

            virtualHost(virtualHostTargetImpl);

            var userTargetImpl = new UserTargetImpl();

            user(userTargetImpl);

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

            LogInfo(
                string.Format(
                    "Sent request to the RabbitMQ server to set permissions for user '{0}' on virtual host '{1}'.",
                    userTargetImpl.Target, virtualHostTargetImpl.Target));

            return(base.Put(url, argsImpl, cancellationToken).Response <ServerResponse>(cancellationToken));
        }
Exemplo n.º 2
0
        public Task<ServerResponse> Set(string userName, Action<UserPermissionsBehavior> args,
                                        CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var argsImpl = new UserPermissionsBehaviorImpl();
            args(argsImpl);

            string url = string.Format("api/permissions/{0}/{1}", Init.VirtualHost.SanitizeVirtualHostName(), userName);

            LogInfo(
                string.Format(
                    "Sent request to the RabbitMQ server to set permissions for user '{0}' on virtual host '{1}'.",
                    userName, Init.VirtualHost));

            return base.Put(url, argsImpl, cancellationToken).Response<ServerResponse>(cancellationToken);
        }
Exemplo n.º 3
0
        public Task<ServerResponse> Set(Action<UserTarget> user, Action<UserPermissionsBehavior> behavior,
                                        Action<VirtualHostTarget> virtualHost,
                                        CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.RequestCanceled(LogInfo);

            var argsImpl = new UserPermissionsBehaviorImpl();
            behavior(argsImpl);

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

            var userTargetImpl = new UserTargetImpl();
            user(userTargetImpl);

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

            LogInfo(
                string.Format(
                    "Sent request to the RabbitMQ server to set permissions for user '{0}' on virtual host '{1}'.",
                    userTargetImpl.Target, virtualHostTargetImpl.Target));

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