Access Request Report

This is an example of an Access Rights Report that is filtered by the instance you are interested in and the for Access Granted and Access Denied events. To filter on Dates as well look at the example above for active cards. The Curl snippet expect that you already know the keys for your instance, and event type you wish to filter for.

Example in C#

var currentInstance  = await client.GetCurrentInstanceAsync();
var app = (await client.GetAppsAsync(currentInstance)).Where(a=> a.ApiKey == "MercuryService").FirstOrDefault(); 
var eventAccessDeniedKey = (await client.GetEventTypesAsync(app)).Where(a=> a.CommonName == "Access Denied").FirstOrDefault()?.Key;
var eventAccessGrantedKey = (await client.GetEventTypesAsync(app)).Where(a=> a.CommonName == "Access Granted").FirstOrDefault()?.Key;

var operations = 
	new BsonDocument[] 
	{ 
	    new BsonDocument("$match", 
	    new BsonDocument("$or", 
	    new BsonArray
	            {
	                new BsonDocument("ObjectLinks.LinkedObjectId", 
	                new ObjectId(eventAccessDeniedKey)),
	                new BsonDocument("ObjectLinks.LinkedObjectId", 
	                new ObjectId(eventAccessDeniedKey))
	            })),
	    new BsonDocument("$match", 
	    new BsonDocument("InFolderId", 
	    new ObjectId(currentInstance.Key))),
	    new BsonDocument("$unwind", 
	    new BsonDocument("path", "$ObjectLinks")),
	    new BsonDocument("$match", 
	    new BsonDocument("ObjectLinks.Relation", "Person")),
	    new BsonDocument("$sort", 
	    new BsonDocument("OccurredOn", -1)),
	    new BsonDocument("$project", 
	    new BsonDocument
	        {
	            { "_id", 1 }, 
	            { "MessageLong", 1 }, 
	            { "ObjectLinks.LinkedObjectId", 1 }, 
	            { "ObjectLinks.Relation", 1 }, 
	            { "OccurredOn", 1 }, 
	            { "EventData.Reader", 1 }, 
	            { "EventData.EncodedCardNumber", 1 }
	        })
	};

var AccessRequest = await client.AggregateAsync(currentInstance, "Events", operations);

Example in CURL

curl -X POST \
  'https://keepapi.feenicshosting.com/api/f/INSTANCE_KEY_HERE/aggregate/Events?queryTimeout=30&jsonStrict=False%20' \
  -H 'Accept: */*' \
  -H 'Authorization: Bearer TOKEN_GOES_HERE \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Host: keepapi.feenicshosting.com' \
  -H 'accept-encoding: gzip, deflate' \
  -H 'cache-control: no-cache' \
  -H 'content-length: 630' \
  -d '["
        { 
            \"$match\" : 
            { 
                \"$or\" : [
                { 
                    \"ObjectLinks.LinkedObjectId\" : ObjectId(\"EVENT_ACCESS_DENIED_KEY\") 
                }, 
                { 
                    \"ObjectLinks.LinkedObjectId\" : ObjectId(\"EVENT_ACCESS_DENIED_KEY\") 
                }
            ] }
        }","
        { 
            \"$match\" : 
            { 
                \"InFolderId\" : ObjectId(\"INSTANCE_KEY_HERE\") 
            } 
        }","
        { 
            \"$unwind\" : 
            { 
                \"path\" : \"$ObjectLinks\" 
            } 
        }","
        { 
            \"$match\" : 
            { 
                \"ObjectLinks.Relation\" : \"Person\" 
            } 
        }","
        { 
            \"$sort\" : 
            { 
                \"OccurredOn\" : -1 
            } 
        }","
        { 
            \"$project\" : 
            { 
                \"_id\" : 1,
                \"MessageLong\" : 1,
                \"ObjectLinks.LinkedObjectId\" : 1, 
                \"ObjectLinks.Relation\" : 1, 
                \"OccurredOn\" : 1, 
                \"EventData.Reader\" : 1, 
                \"EventData.EncodedCardNumber\" : 1 
            } 
        }"
    ]'

Example Of Aggregate Used in JSON

[
    { 
        "$match" : 
        { 
            "$or" : [
                { 
                    "ObjectLinks.LinkedObjectId" : ObjectId("EVENT_ACCESS_DENIED_KEY") 
                }, 
                { 
                    "ObjectLinks.LinkedObjectId" : ObjectId("EVENT_ACCESS_DENIED_KEY") 
                }
            ] 
        }
    },
    { 
        "$match" : 
        { 
            "InFolderId" : ObjectId("INSTANCE_KEY_HERE") 
        } 
    },
    { 
        "$unwind" : 
        { 
            "path" : "$ObjectLinks" 
        } 
    },
    { 
        "$match" : 
        { 
            "ObjectLinks.Relation" : "Person" 
        } 
    },
    { 
        "$sort" : 
        { 
            "OccurredOn" : -1 
        } 
    },
    { 
        "$project" : 
        { 
            "_id" : 1,
            "MessageLong" : 1,
            "ObjectLinks.LinkedObjectId" : 1, 
            "ObjectLinks.Relation" : 1, 
            "OccurredOn" : 1, 
            "EventData.Reader" : 1, 
            "EventData.EncodedCardNumber" : 1 
        } 
    }
]