Esempio n. 1
0
 /// <summary>
 /// UserGrantRoleAsync grants a role to a specified user in async
 /// </summary>
 /// <param name="request">The request to send to the server.</param>
 /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 /// <param name="cancellationToken">An optional token for canceling the call.</param>
 /// <returns>The response received from the server.</returns>
 public async Task <AuthUserGrantRoleResponse> UserGrantRoleAsync(AuthUserGrantRoleRequest request,
                                                                  Grpc.Core.Metadata headers          = null, DateTime?deadline = null,
                                                                  CancellationToken cancellationToken = default)
 {
     return(await CallEtcdAsync(async (connection) => await connection._authClient
                                .UserGrantRoleAsync(request, headers, deadline, cancellationToken)).ConfigureAwait(false));
 }
Esempio n. 2
0
 /// <summary>
 /// UserGrant grants a role to a specified user
 /// </summary>
 /// <param name="request">The request to send to the server.</param>
 /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
 /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
 /// <param name="cancellationToken">An optional token for canceling the call.</param>
 /// <returns>The response received from the server.</returns>
 public AuthUserGrantRoleResponse UserGrantRole(AuthUserGrantRoleRequest request,
                                                Grpc.Core.Metadata headers          = null, DateTime?deadline = null,
                                                CancellationToken cancellationToken = default)
 {
     return(CallEtcd((connection) => connection._authClient
                     .UserGrantRole(request, headers, deadline, cancellationToken)));
 }
Esempio n. 3
0
        /// <summary>
        /// UserGrantRoleAsync grants a role to a specified user in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AuthUserGrantRoleResponse> UserGrantRoleAsync(AuthUserGrantRoleRequest request, Metadata headers = null)
        {
            AuthUserGrantRoleResponse response = new AuthUserGrantRoleResponse();
            bool success    = false;
            int  retryCount = 0;

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

                    success = true;
                }
                catch (RpcException ex) when(ex.StatusCode == StatusCode.Unavailable)
                {
                    retryCount++;
                    if (retryCount >= _balancer._numNodes)
                    {
                        throw ex;
                    }
                }
            }
            return(response);
        }
Esempio n. 4
0
        /// <summary>
        /// UserGrantRoleAsync grants a role to a specified user in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AuthUserGrantRoleResponse> UserGrantRoleAsync(AuthUserGrantRoleRequest request, Metadata headers = null)
        {
            AuthUserGrantRoleResponse response = new AuthUserGrantRoleResponse();

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

            return(response);
        }
Esempio n. 5
0
        /// <summary>
        /// UserGrant grants a role to a specified user
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public AuthUserGrantRoleResponse UserGrantRole(AuthUserGrantRoleRequest request, Metadata headers = null)
        {
            AuthUserGrantRoleResponse response = new AuthUserGrantRoleResponse();

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

            return(response);
        }
Esempio n. 6
0
        /// <summary>
        /// UserGrantRoleAsync grants a role to a specified user in async
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <AuthUserGrantRoleResponse> UserGrantRoleAsync(AuthUserGrantRoleRequest request)
        {
            AuthUserGrantRoleResponse response = new AuthUserGrantRoleResponse();

            try
            {
                response = await _authClient.UserGrantRoleAsync(request, _headers);
            }
            catch (RpcException ex)
            {
                ResetConnection(ex);
                throw;
            }
            catch
            {
                throw;
            }
            return(response);
        }
Esempio n. 7
0
        /// <summary>
        /// UserGrant grants a role to a specified user
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public AuthUserGrantRoleResponse UserGrantRole(AuthUserGrantRoleRequest request)
        {
            AuthUserGrantRoleResponse response = new AuthUserGrantRoleResponse();

            try
            {
                response = _authClient.UserGrantRole(request, _headers);
            }
            catch (RpcException ex)
            {
                ResetConnection(ex);
                throw;
            }
            catch
            {
                throw;
            }
            return(response);
        }