public void PostSearchTest() { // TODO: add unit test for the method 'PostSearch' GroupSearchRequest body = null; // TODO: replace null with proper value var response = instance.PostSearch(body); Assert.IsInstanceOf <GroupsSearchResponse> (response, "response is GroupsSearchResponse"); }
public async Task <IEnumerable <GroupViewModel> > Search(GroupSearchRequest request) { var json = JsonConvert.SerializeObject(request); _logger.LogInformation($"teams.by.query ${json}"); var data = (await _service.SearchAsync(request)).ToList(); _logger.LogInformation($"found.teams {data.Count}"); return(data); }
public IHttpActionResult Query([FromUri] GroupSearchRequest searchRequest) { Stopwatch stopwatch = start(); Exception exception = null; List <Group> users = null; try { if (null == searchRequest || false == searchRequest.IsAnythingSet) { users = _provider.GetAllGroups(); } else { users = _provider.Search(searchRequest); } } catch (HardFailureException hardFailure) { exception = hardFailure; _logger.Write( hardFailure.Message, LogEntrySeverityEnum.Error, hardFailure); } catch (Exception ex) { exception = ex; _logger.Write( "An unknown error occurred. ", LogEntrySeverityEnum.Error, ex); } stop(stopwatch, "Group.Query"); if (null == exception && null == users) { return(InternalServerError()); } else if (null == exception) { return(Ok(users)); } else { return(InternalServerError(exception)); } }
public IHttpActionResult Search(string gid) { Stopwatch stopwatch = start(); Exception exception = null; List <Group> users = null; try { GroupSearchRequest searchRequest = new GroupSearchRequest(); searchRequest.GID = gid; users = _provider.Search(searchRequest); } catch (HardFailureException hardFailure) { exception = hardFailure; _logger.Write( hardFailure.Message, LogEntrySeverityEnum.Error, hardFailure); } catch (Exception ex) { exception = ex; _logger.Write( "An unknown error occurred. ", LogEntrySeverityEnum.Error, ex); } stop(stopwatch, "Group.Search"); if (null == exception && null == users) { return(InternalServerError()); } else if (null == exception) { if (users.Count != 1) { return(NotFound()); } return(Ok(users[0])); } else { return(InternalServerError(exception)); } }
public async Task <List <Group> > Search([FromQuery] GroupSearchRequest request) { var groups = (List <Group>)null; try { groups = await _groupsRepository.GetByNameLike(request.Name); } catch (Exception ex) { Console.WriteLine(ex.Message); HttpContext.Response.StatusCode = StatusCodes.Status500InternalServerError; } return(groups); }
public List <Group> Search(GroupSearch search) { GroupSearchRequest request = new GroupSearchRequest(); request.FromGroupSearch(search); string requestURL = "group/query" + request.ToQueryString(); var response = GetHttpClient().GetAsync(requestURL).Result; if (!response.IsSuccessStatusCode) { ToApplicationException(response); } return(response.Content.ReadAsAsync <List <Group> >().Result); }
public async Task <IEnumerable <Models.Group> > SearchAsync(GroupSearchRequest request, bool fullQuery = false) { var builder = Builders <Models.Group> .Filter; var filter = builder.Empty; if (!string.IsNullOrWhiteSpace(request.Query)) { var regex = new BsonRegularExpression(request.Query, "i"); filter = builder.Or( builder.Regex(x => x.Name, regex), builder.Regex(x => x.Description, regex), builder.Regex(x => x.Tag, regex) ); } return(await _context.Groups .Find(filter) .Skip(request.Skip) .Limit(request.Limit) .ToListAsync()); }
/// <summary> /// Search and Get a PureCloud group using its name or id. /// </summary> /// <param name="name"></param> /// <param name="api"></param> /// <returns></returns> private static GroupsSearchResponse GetGroup(string name, GroupsApi api) { // Search criteria is group name with exact value GroupSearchCriteria criteria = new GroupSearchCriteria(Value: name, _Operator: GroupSearchCriteria.OperatorEnum.And, Fields: (new List <string> { "name" }), Type: GroupSearchCriteria.TypeEnum.Exact); // Add criteria to Group Search Criteria List List <GroupSearchCriteria> groupSearchCriteriaList = new List <GroupSearchCriteria>(); groupSearchCriteriaList.Add(criteria); // Build list of Group Search Criteria GroupSearchRequest request = new GroupSearchRequest(); request.Query = groupSearchCriteriaList; return(api.PostGroupsSearch(request)); }
public async Task <FabricIdentityGroupResponse> SearchGroupAsync(GroupSearchRequest request) { var route = $"{PrincipalsEndpoint}{request.IdentityProvider}/groups/{request.DisplayName}"; if (!string.IsNullOrWhiteSpace(request.TenantId)) { route = $"{route}?tenantId={request.TenantId}"; } var httpRequestMessage = await CreateHttpRequestMessage(route, HttpMethod.Get); _logger.Debug($"Invoking {ServiceName} endpoint {httpRequestMessage.RequestUri}"); httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json"); var response = await _httpClient.SendAsync(httpRequestMessage); var responseContent = response.Content == null ? string.Empty : await response.Content.ReadAsStringAsync(); var results = new GroupSearchResponse(); if (response.StatusCode != HttpStatusCode.OK) { this.LogNonOkResponse(httpRequestMessage, response, responseContent); } else { results = JsonConvert.DeserializeObject <GroupSearchResponse>(responseContent); _logger.Debug($"{ServiceName} {httpRequestMessage.RequestUri} result: {results}"); } return(new FabricIdentityGroupResponse { HttpStatusCode = response.StatusCode, Results = results.Principals }); }
public object Get(GroupSearchRequest request) { var context = TepWebContext.GetWebContext(PagePrivileges.UserView); context.Open(); context.LogInfo(this, string.Format("/user/search GET")); EntityList <Group> groups = new EntityList <Group>(context); groups.AddSort("Identifier", SortDirection.Ascending); // Load the complete request HttpRequest httpRequest = HttpContext.Current.Request; OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine; Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose); IOpenSearchResultCollection osr = ose.Query(groups, httpRequest.QueryString, responseType); OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(groups, osr); context.Close(); return(new HttpResult(osr.SerializeToString(), osr.ContentType)); }
public void Init() { instance = new GroupSearchRequest(); }
public async Task <IEnumerable <GroupViewModel> > SearchAsync(GroupSearchRequest request) { var data = await _repository.SearchAsync(request); return(_mapper.Map <IEnumerable <GroupViewModel> >(data)); }