示例#1
0
        public async Task <UserDetails> GetUserAsync(string loginName, UserCredentials?userCredentials = null,
                                                     CancellationToken cancellationToken = default)
        {
            if (loginName == null)
            {
                throw new ArgumentNullException(nameof(loginName));
            }

            if (loginName == string.Empty)
            {
                throw new ArgumentOutOfRangeException(nameof(loginName));
            }

            using var call = new Users.Users.UsersClient(
                      await SelectCallInvoker(cancellationToken).ConfigureAwait(false)).Details(new DetailsReq {
                Options = new DetailsReq.Types.Options {
                    LoginName = loginName
                }
            }, EventStoreCallOptions.Create(Settings, Settings.OperationOptions, userCredentials, cancellationToken));

            await call.ResponseStream.MoveNext().ConfigureAwait(false);

            var userDetails = call.ResponseStream.Current.UserDetails;

            return(ConvertUserDetails(userDetails));
        }
 public EventStoreUserManagementClient(EventStoreClientSettings?settings = null) :
     base(settings, ExceptionMap)
 {
     _client = new Users.Users.UsersClient(CallInvoker);
     _log    = Settings.LoggerFactory?.CreateLogger <EventStoreUserManagementClient>() ??
               new NullLogger <EventStoreUserManagementClient>();
 }
示例#3
0
        public async IAsyncEnumerable <UserDetails> ListAllAsync(UserCredentials?userCredentials = null,
                                                                 [EnumeratorCancellation] CancellationToken cancellationToken = default)
        {
            using var call = new Users.Users.UsersClient(
                      await SelectCallInvoker(cancellationToken).ConfigureAwait(false)).Details(new DetailsReq(),
                                                                                                EventStoreCallOptions.Create(Settings, Settings.OperationOptions, userCredentials, cancellationToken));

            await foreach (var userDetail in call.ResponseStream
                           .ReadAllAsync(cancellationToken)
                           .Select(x => ConvertUserDetails(x.UserDetails))
                           .WithCancellation(cancellationToken)
                           .ConfigureAwait(false))
            {
                yield return(userDetail);
            }
        }