Пример #1
0
        protected override void ProcessRecord()
        {
            if (!string.IsNullOrEmpty(Id))
            {
                WriteObject(OperationalInsightsClient.GetSearchResultsUpdate(ResourceGroupName, WorkspaceName, Id), true);
            }
            else if (!string.IsNullOrEmpty(Query))
            {
                PSHighlight highlight = new PSHighlight()
                {
                    Pre  = PreHighlight,
                    Post = PostHighlight
                };

                PSSearchGetSearchResultsParameters parameters = new PSSearchGetSearchResultsParameters()
                {
                    Top       = Top,
                    Highlight = highlight,
                    Query     = Query,
                    Start     = Start,
                    End       = End,
                };

                WriteObject(OperationalInsightsClient.GetSearchResults(ResourceGroupName, WorkspaceName, parameters), true);
            }
            else
            {
                ThrowTerminatingError(new ErrorRecord(new ArgumentException("Either the Query or Id parameter must be provided"), "QueryOrIdRequired", ErrorCategory.InvalidArgument, null));
            }
        }
Пример #2
0
        protected override void ProcessRecord()
        {
            if (Id != null)
            {
                WriteObject(OperationalInsightsClient.GetSearchResultsUpdate(ResourceGroupName, WorkspaceName, Id), true);
            }
            else
            {
                PSHighlight highlight = new PSHighlight()
                {
                    Pre  = PreHighlight,
                    Post = PostHighlight
                };
                PSSearchGetSearchResultsParameters parameters = new PSSearchGetSearchResultsParameters()
                {
                    Top       = Top,
                    Highlight = highlight,
                    Query     = Query,
                    Start     = Start,
                    End       = End,
                };

                WriteObject(OperationalInsightsClient.GetSearchResults(ResourceGroupName, WorkspaceName, parameters), true);
            }
        }
        public virtual PSSearchGetSearchResultsResponse GetSearchResults(string resourceGroupName, string workspaceName, PSSearchGetSearchResultsParameters psParameters)
        {
            SearchGetSearchResultsParameters parameters = new SearchGetSearchResultsParameters();

            parameters.Top = psParameters.Top;
            if (psParameters.Highlight != null)
            {
                parameters.Highlight      = new Highlight();
                parameters.Highlight.Pre  = psParameters.Highlight.Pre;
                parameters.Highlight.Post = psParameters.Highlight.Post;
            }
            parameters.Query = psParameters.Query;
            parameters.Start = psParameters.Start;
            parameters.End   = psParameters.End;

            SearchGetSearchResultsResponse   response       = OperationalInsightsManagementClient.Search.GetSearchResults(resourceGroupName, workspaceName, parameters);
            PSSearchGetSearchResultsResponse searchResponse = new PSSearchGetSearchResultsResponse(response);

            return(searchResponse);
        }
Пример #4
0
        public virtual PSSearchGetSearchResultsResponse GetSearchResults(string resourceGroupName, string workspaceName, PSSearchGetSearchResultsParameters psParameters)
        {
            SearchParameters parameters = new SearchParameters();

            if (psParameters.Highlight != null)
            {
                parameters.Highlight      = new SearchHighlight();
                parameters.Highlight.Pre  = psParameters.Highlight.Pre;
                parameters.Highlight.Post = psParameters.Highlight.Post;
            }

            parameters.Top   = psParameters.Top == 0 ? 10 : psParameters.Top;
            parameters.Query = psParameters.Query;
            parameters.Start = psParameters.Start;
            parameters.End   = psParameters.End.GetValueOrDefault(DateTime.UtcNow);

            SearchResultsResponse            response       = OperationalInsightsManagementClient.Workspaces.GetSearchResults(resourceGroupName, workspaceName, parameters);
            PSSearchGetSearchResultsResponse searchResponse = new PSSearchGetSearchResultsResponse(response);

            return(searchResponse);
        }