Get audits - Metasys - LIT-12013522 - Software Application - Basic Services client library for .NET (and COM) - Metasys API - 4.2

Metasys REST Client for .NET and COM Developer Guide

Brand
Metasys
Product name
Basic Services client library for .NET (and COM)
Metasys API
Document type
API Reference Guide
Document number
LIT-12013522
Version
4.2
Revision date
2021-04-07
Language
English

To get all available audits, use the Get method. The library delivers a PagedResult that contains a list of Audit. The Get method accepts the AuditFilter object to filter the response.

Use the object AuditFilter to set criteria to filter the audits retrieved by the Get method. The following list explains the attributes you can use in AuditFilter.
  • StartTime: the date and time the method starts to collect the audits.
  • EndTime: the date and time the method stops collecting the audits.
  • OriginApplications: use to filter the audits according to the type of applications that generated them. If you have many application origins, use a list of enumerated values from the OriginApplicationsEnum set, concatenate each one with the pipe character.
  • ActionTypes: use to filter the audits according to the type of actions that generated them. If you have many actions, use a list of enumerated values from the ActionTypeEnum set, concatenate each one with the pipe character.
Table 1. Get audits .NET signature
Library method name Get
Description Get all available audits.
Method signature PagedResult<Audit> Get(AuditFilter auditFilter);
Method input parameters auditFilter: the object used by the method to specify the criteria to use to filter the target audits.
Return value A PagedResult of Audit.

The following .NET C# code is an example of a successful get audits response:

AuditFilter auditFilter = new AuditFilter
  {
    StartTime = new DateTime(2020, 06, 01),
    EndTime = new DateTime(2020, 06, 24),
    OriginApplications = OriginApplicationsEnum.SystemSecurity | OriginApplicationsEnum.AuditTrails,
    ActionTypes = ActionTypeEnum.Subsystem | ActionTypeEnum.Command
  };
PagedResult<Audit> auditsPager = client.Audits.Get(auditFilter);
// Prints the number of records fetched and paging information
Console.WriteLine("Total:" + auditsPager.Total);
Console.WriteLine("Current page:" + auditsPager.CurrentPage);
Console.WriteLine("Page size:" + auditsPager.PageSize);
Console.WriteLine("Pages:" + auditsPager.PageCount);
/*                       
  Total:323
  Current page:1
  Page size:100
  Pages:4
*/
Audit audit = auditsPager.Items.FirstOrDefault();
Console.WriteLine(audit);
/*                       
  {
    "Id": "8e3b3738-2f5f-494d-bde1-fac15da28c86",
    "CreationTime": "2020-06-23T16:45:54.697Z",
    "ActionTypeUrl": null,
    "ActionType": "auditActionTypeEnumSet.subsystemAuditActionType",
    "Discarded": false,
    "StatusUrl": null,
    "Status": null,
    "PreData": null,
    "PostData": "::1",
    "Parameters": "[]",
    "ErrorString": null,
    "User": "testuser",
    "Signature": null,
    "ObjectUrl": "https://win-21dj9jv9qh6/api/v3/objects/1949c631-7823-5230-b951-aae3f8c9d64a",
    "AnnotationsUrl": null,
    "Legacy": 
    {
      "FullyQualifiedItemReference": "WIN-21DJ9JV9QH6:WIN-21DJ9JV9QH6",
      "ItemName": "EECMI-ADS11",
      "ClassLevel": "auditClassesEnumSet.userActionAuditClass",
      "OriginApplication": "auditOriginAppEnumSet.systemSecurityAuditOriginApp",
      "Description": "auditTrailStringsEnumSet.atstrSecurityUserLoginSuccessful"
    },
    "Self": "https://win-21dj9jv9qh6/api/v3/audits/8e3b3738-2f5f-494d-bde1-fac15da28c86"
  }
*/