| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.ComponentModel.DataAnnotations;
- namespace Domain.Entities.Developers;
- /// <summary>
- /// 공개 API (/v1/*) 호출 로그.
- /// 집계/모니터링/Rate limit 분석용. 1 row = 1 호출.
- /// ApplicationID(OAuth2) 또는 PatID(PAT) 중 하나가 채워짐.
- /// </summary>
- public class ApiRequestLog
- {
- [Key]
- public long ID { get; private set; }
- public int? ApplicationID { get; private set; }
- public long? PatID { get; private set; }
- public string Endpoint { get; private set; } = default!;
- public string Method { get; private set; } = default!;
- public int StatusCode { get; private set; }
- public int ResponseMs { get; private set; }
- public string? IpAddress { get; private set; }
- public DateTime RequestedAt { get; private set; } = DateTime.UtcNow;
- private ApiRequestLog() { }
- public static ApiRequestLog Create(
- int? applicationID,
- long? patID,
- string endpoint,
- string method,
- int statusCode,
- int responseMs,
- string? ipAddress
- )
- {
- return new ApiRequestLog
- {
- ApplicationID = applicationID,
- PatID = patID,
- Endpoint = endpoint,
- Method = method,
- StatusCode = statusCode,
- ResponseMs = responseMs,
- IpAddress = ipAddress
- };
- }
- }
|