Exemple #1
0
        public override void ExecuteCmdlet()
        {
            int    numberOfFetchedIncidentComments = 0;
            string nextLink = null;

            switch (ParameterSetName)
            {
            case ParameterSetNames.IncidentId:
                var incidentComments      = SecurityInsightsClient.IncidentComments.ListByIncident(ResourceGroupName, WorkspaceName, IncidentId);
                int incidentCommentsCount = incidentComments.Count();
                WriteObject(incidentComments.ConvertToPSType(), enumerateCollection: true);
                numberOfFetchedIncidentComments += incidentCommentsCount;
                nextLink = incidentComments?.NextPageLink;
                while (!string.IsNullOrWhiteSpace(nextLink) && numberOfFetchedIncidentComments < MaxIncidentCommentsToFetch)
                {
                    incidentComments      = SecurityInsightsClient.IncidentComments.ListByIncidentNext(incidentComments.NextPageLink);
                    incidentCommentsCount = incidentComments.Count();
                    WriteObject(incidentComments.ConvertToPSType(), enumerateCollection: true);
                    numberOfFetchedIncidentComments += incidentCommentsCount;
                    nextLink = incidentComments?.NextPageLink;
                }
                break;

            case ParameterSetNames.IncidentCommentId:
                var incidentComment = SecurityInsightsClient.IncidentComments.Get(ResourceGroupName, WorkspaceName, IncidentId, IncidentCommentId);
                WriteObject(incidentComment.ConvertToPSType(), enumerateCollection: false);
                break;

            case ParameterSetNames.ResourceId:
                incidentComment = SecurityInsightsClient.IncidentComments.Get(ResourceGroupName, WorkspaceName, AzureIdUtilities.GetIncidentName(ResourceId), AzureIdUtilities.GetIncidentCommentName(ResourceId));
                WriteObject(incidentComment.ConvertToPSType(), enumerateCollection: false);
                break;

            default:
                throw new PSInvalidOperationException();
            }
        }