/// <summary> /// Retrieve all tags /// </summary> /// <param name="detailsLevel">details level</param> /// <returns>List of tags</returns> public async ValueTask <JsonElement?> GetTags(DetailsLevel detailsLevel = DetailsLevel.Standard) { var queryParams = new Dictionary <string, string>() { { "details-level", detailsLevelParamStrings[detailsLevel] }, }; string queryRequestParamsJsonString = JsonSerializer.Serialize(queryParams); using var queryRequestParamsJsonDocument = JsonDocument.Parse(queryRequestParamsJsonString); var queryRequestParamsJsonElement = queryRequestParamsJsonDocument.RootElement; try { var queryResponse = await _interactions.Query(getTagsQueryId, queryRequestParamsJsonElement); return(queryResponse); } catch (Exception error) { Console.Error.WriteLine("Failed to get tags - " + error); return(null); } }
public IPagedReader <TransportQueueStatistics> FindTransportQueueInfo(Guid forestId, string aggregatedBy, TimeSpan freshnessCutoffTime, MultiValuedProperty <Guid> adSiteIdList = null, MultiValuedProperty <Guid> dagIdList = null, MultiValuedProperty <Guid> serverIdList = null, MultiValuedProperty <ComparisonFilter> dataFilter = null, DetailsLevel detailsLevel = DetailsLevel.None, int pageSize = 100, int detailsResultsSize = 20) { if (forestId == Guid.Empty) { throw new ArgumentNullException("forestId"); } if (string.IsNullOrWhiteSpace(aggregatedBy)) { throw new ArgumentNullException("aggregatedBy"); } QueryFilter filter = new AndFilter(new ComparisonFilter[] { new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.ForestIdQueryProperty, forestId), new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.AggregatedByQueryProperty, aggregatedBy), new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.FreshnessCutoffTimeSecondsProperty, freshnessCutoffTime.TotalSeconds), new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.DetailsLevelQueryProperty, detailsLevel), new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.PageSizeQueryProperty, pageSize), new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.DetailsResultSizeQueryProperty, detailsResultsSize), new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.ADSiteQueryProperty, TransportQueueSession.GetFilter(adSiteIdList)), new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.DagQueryProperty, TransportQueueSession.GetFilter(dagIdList)), new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.ServerQueryProperty, TransportQueueSession.GetFilter(serverIdList)), new ComparisonFilter(ComparisonOperator.Equal, TransportQueueStatisticsSchema.DataFilterQueryProperty, TransportQueueSession.GetDataFilter(dataFilter)) }); return(this.FindTransportQueueInfo(filter, pageSize)); }
/// <summary> /// Retrieve task by task uid /// </summary> /// <param name="uid">object uid</param> /// <param name="detailsLevel">details level</param> /// <param name="wait">wait</param> /// <returns>A Tuple with Task object and TaskStatus</returns> public async ValueTask <(JsonElement?TaskObject, TaskStatus?TaskStatusCode)> GetTaskWithTaskStatus(string uid, DetailsLevel detailsLevel = DetailsLevel.Standard, bool wait = true) { var queryParams = new Dictionary <string, string>() { { "task-id", uid }, { "details-level", detailsLevelParamStrings[detailsLevel] }, }; string queryRequestParamsJsonString = JsonSerializer.Serialize(queryParams); using var queryRequestParamsJsonDocument = JsonDocument.Parse(queryRequestParamsJsonString); var queryRequestParamsJsonElement = queryRequestParamsJsonDocument.RootElement; try { string status; var taskResult = CheckTaskResult(await GetTaskInternal(queryRequestParamsJsonElement), out status); while (wait && (status == taskStatusReturnStrings[TaskStatus.InProgress])) { await Task.Delay(5000); taskResult = CheckTaskResult(await GetTaskInternal(queryRequestParamsJsonElement), out status); } TaskStatus?taskStatusCode = null; foreach (var taskStatusKey in taskStatusReturnStrings.Keys) { if (status == taskStatusReturnStrings[taskStatusKey]) { taskStatusCode = taskStatusKey; break; } } await Done.InvokeAsync(); // Notify the subscriber return(taskResult, taskStatusCode); } catch (Exception error) { Console.Error.WriteLine("Failed to get task (" + uid + ") - " + error); return(null, null); } }
/// <summary> /// Retrieve task by task uid /// </summary> /// <param name="uid">object uid</param> /// <param name="detailsLevel">details level</param> /// <param name="wait">wait</param> /// <returns>Task object</returns> public async ValueTask <JsonElement?> GetTask(string uid, DetailsLevel detailsLevel = DetailsLevel.Standard, bool wait = true) { var result = await GetTaskWithTaskStatus(uid, detailsLevel, wait); return(result.TaskObject); }
/// <summary> /// Retrieve objects tagged by tag uid /// </summary> /// <param name="tag">tag uid</param> /// <param name="type">object type</param> /// <param name="detailsLevel">details level</param> /// <returns>List of objects</returns> public async ValueTask <JsonElement?> GetObjectsByTag(string tag, string type = defaultObjectType, DetailsLevel detailsLevel = DetailsLevel.Standard) { var queryParams = new GetObjectsByQueryParams() { @in = new List <string> { getObjectsQueryByTag, tag }, type = type, DetailsLevel = detailsLevelParamStrings[detailsLevel] }; string queryRequestParamsJsonString = JsonSerializer.Serialize(queryParams); using var queryRequestParamsJsonDocument = JsonDocument.Parse(queryRequestParamsJsonString); var queryRequestParamsJsonElement = queryRequestParamsJsonDocument.RootElement; try { var queryResponse = await _interactions.Query(getObjectsQueryId, queryRequestParamsJsonElement); return(queryResponse); } catch (Exception error) { Console.Error.WriteLine("Failed to get objects - " + error); return(null); } }