/// <summary>
        /// RoleGrantPermissionAsync grants a permission of a specified key or range to a specified role in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AuthRoleGrantPermissionResponse> RoleGrantPermissionAsync(AuthRoleGrantPermissionRequest request, Metadata headers = null)
        {
            AuthRoleGrantPermissionResponse response = new AuthRoleGrantPermissionResponse();
            bool success    = false;
            int  retryCount = 0;

            while (!success)
            {
                try
                {
                    response = await _balancer.GetConnection().authClient.RoleGrantPermissionAsync(request, headers);

                    success = true;
                }
                catch (RpcException ex) when(ex.StatusCode == StatusCode.Unavailable)
                {
                    retryCount++;
                    if (retryCount >= _balancer._numNodes)
                    {
                        throw ex;
                    }
                }
            }
            return(response);
        }
Exemple #2
0
        /// <summary>
        /// RoleGrantPermissionAsync grants a permission of a specified key or range to a specified role in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AuthRoleGrantPermissionResponse> RoleGrantPermissionAsync(AuthRoleGrantPermissionRequest request, Metadata headers = null)
        {
            AuthRoleGrantPermissionResponse response = new AuthRoleGrantPermissionResponse();

            response = await _balancer.GetConnection().authClient.RoleGrantPermissionAsync(request, headers);

            return(response);
        }
Exemple #3
0
        /// <summary>
        /// RoleGrantPermission grants a permission of a specified key or range to a specified role
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public AuthRoleGrantPermissionResponse RoleGrantPermission(AuthRoleGrantPermissionRequest request, Metadata headers = null)
        {
            AuthRoleGrantPermissionResponse response = new AuthRoleGrantPermissionResponse();

            response = _balancer.GetConnection().authClient.RoleGrantPermission(request, headers);

            return(response);
        }
Exemple #4
0
        /// <summary>
        /// RoleGrantPermissionAsync grants a permission of a specified key or range to a specified role in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AuthRoleGrantPermissionResponse> RoleGrantPermissionAsync(AuthRoleGrantPermissionRequest request)
        {
            AuthRoleGrantPermissionResponse response = new AuthRoleGrantPermissionResponse();

            try
            {
                response = await _authClient.RoleGrantPermissionAsync(request, _headers);
            }
            catch (RpcException ex)
            {
                ResetConnection(ex);
                throw;
            }
            catch
            {
                throw;
            }
            return(response);
        }
Exemple #5
0
        public AuthRoleGrantPermissionResponse RoleGrantPermission(ByteSequence role,
                                                                   ByteSequence key, ByteSequence rangeEnd, auth.Permission.Type permType)
        {
            Authpb.Permission.Types.Type type;
            switch (permType)
            {
            case Permission.Type.WRITE:
                type = Authpb.Permission.Types.Type.Write;
                break;

            case Permission.Type.READWRITE:
                type = Authpb.Permission.Types.Type.Readwrite;
                break;

            case Permission.Type.READ:
                type = Authpb.Permission.Types.Type.Read;
                break;

            default:
                type = Authpb.Permission.Types.Type.Readwrite;
                break;
            }
            Authpb.Permission perm = new Authpb.Permission();
            perm.Key      = key.GetByteString();
            perm.RangeEnd = rangeEnd.GetByteString();
            perm.PermType = type;
            Etcdserverpb.AuthRoleGrantPermissionRequest roleGrantPermissionRequest = new Etcdserverpb.AuthRoleGrantPermissionRequest();
            roleGrantPermissionRequest.Name = role.ToString();
            roleGrantPermissionRequest.Perm = perm;
            var rsp = authClient.RoleGrantPermission(roleGrantPermissionRequest);
            AuthRoleGrantPermissionResponse response = new AuthRoleGrantPermissionResponse(rsp);

            return(response);
            // return Util.ToCompletableFuture(
            // this.stub.roleGrantPermission(roleGrantPermissionRequest),
            //  new FunctionResponse<Etcdserverpb.AuthRoleGrantPermissionRequest, AuthRoleGrantPermissionResponse>());
        }