using Bit.Core.AdminConsole.Entities;
using Bit.Core.Dirt.Enums;
using Bit.Core.Dirt.Models.Data.EventIntegrations;
using Bit.Core.Enums;
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
namespace Bit.Core.Utilities;
///
/// Provides cache key generation helpers and cache name constants for event integration–related entities.
///
public static class EventIntegrationsCacheConstants
{
///
/// The base cache name used for storing event integration data.
///
public const string CacheName = "EventIntegrations";
///
/// Duration TimeSpan for adding OrganizationIntegrationConfigurationDetails to the cache.
///
public static readonly TimeSpan DurationForOrganizationIntegrationConfigurationDetails = TimeSpan.FromDays(1);
///
/// Builds a deterministic cache key for a .
///
/// The unique identifier of the group.
///
/// A cache key for this Group.
///
public static string BuildCacheKeyForGroup(Guid groupId) =>
$"Group:{groupId:N}";
///
/// Builds a deterministic cache key for an .
///
/// The unique identifier of the organization.
///
/// A cache key for the Organization.
///
public static string BuildCacheKeyForOrganization(Guid organizationId) =>
$"Organization:{organizationId:N}";
///
/// Builds a deterministic cache key for an organization user .
///
/// The unique identifier of the organization to which the user belongs.
/// The unique identifier of the user.
///
/// A cache key for the user.
///
public static string BuildCacheKeyForOrganizationUser(Guid organizationId, Guid userId) =>
$"OrganizationUserUserDetails:{organizationId:N}:{userId:N}";
///
/// Builds a deterministic cache key for an organization's integration configuration details
/// .
///
/// The unique identifier of the organization.
/// The of the integration.
/// The specific of the event configured.
///
/// A cache key for the configuration details.
///
public static string BuildCacheKeyForOrganizationIntegrationConfigurationDetails(
Guid organizationId,
IntegrationType integrationType,
EventType eventType
) => $"OrganizationIntegrationConfigurationDetails:{organizationId:N}:{integrationType}:{eventType}";
///
/// Builds a deterministic tag for tagging an organization's integration configuration details. This tag is then
/// used to tag all of the that result from this
/// integration, which allows us to remove all relevant entries when an integration is changed or removed.
///
/// The unique identifier of the organization to which the user belongs.
/// The of the integration.
///
/// A cache tag to use for the configuration details.
///
public static string BuildCacheTagForOrganizationIntegration(
Guid organizationId,
IntegrationType integrationType
) => $"OrganizationIntegration:{organizationId:N}:{integrationType}";
}