// File generated from our OpenAPI spec by Stainless.

package com.openai.models.admin.organization.auditlogs

import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.openai.core.JsonValue
import com.openai.core.jsonMapper
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class AuditLogListPageResponseTest {

    @Test
    fun create() {
        val auditLogListPageResponse =
            AuditLogListPageResponse.builder()
                .addData(
                    AuditLogListResponse.builder()
                        .id("id")
                        .effectiveAt(0L)
                        .type(AuditLogListResponse.Type.API_KEY_CREATED)
                        .actor(
                            AuditLogListResponse.Actor.builder()
                                .apiKey(
                                    AuditLogListResponse.Actor.ApiKey.builder()
                                        .id("id")
                                        .serviceAccount(
                                            AuditLogListResponse.Actor.ApiKey.ServiceAccount
                                                .builder()
                                                .id("id")
                                                .build()
                                        )
                                        .type(AuditLogListResponse.Actor.ApiKey.Type.USER)
                                        .user(
                                            AuditLogListResponse.Actor.ApiKey.User.builder()
                                                .id("id")
                                                .email("email")
                                                .build()
                                        )
                                        .build()
                                )
                                .session(
                                    AuditLogListResponse.Actor.Session.builder()
                                        .ipAddress("ip_address")
                                        .user(
                                            AuditLogListResponse.Actor.Session.User.builder()
                                                .id("id")
                                                .email("email")
                                                .build()
                                        )
                                        .build()
                                )
                                .type(AuditLogListResponse.Actor.Type.SESSION)
                                .build()
                        )
                        .apiKeyCreated(
                            AuditLogListResponse.ApiKeyCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.ApiKeyCreated.Data.builder()
                                        .addScope("string")
                                        .build()
                                )
                                .build()
                        )
                        .apiKeyDeleted(
                            AuditLogListResponse.ApiKeyDeleted.builder().id("id").build()
                        )
                        .apiKeyUpdated(
                            AuditLogListResponse.ApiKeyUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.ApiKeyUpdated.ChangesRequested.builder()
                                        .addScope("string")
                                        .build()
                                )
                                .build()
                        )
                        .certificateCreated(
                            AuditLogListResponse.CertificateCreated.builder()
                                .id("id")
                                .name("name")
                                .build()
                        )
                        .certificateDeleted(
                            AuditLogListResponse.CertificateDeleted.builder()
                                .id("id")
                                .certificate("certificate")
                                .name("name")
                                .build()
                        )
                        .certificateUpdated(
                            AuditLogListResponse.CertificateUpdated.builder()
                                .id("id")
                                .name("name")
                                .build()
                        )
                        .certificatesActivated(
                            AuditLogListResponse.CertificatesActivated.builder()
                                .addCertificate(
                                    AuditLogListResponse.CertificatesActivated.Certificate.builder()
                                        .id("id")
                                        .name("name")
                                        .build()
                                )
                                .build()
                        )
                        .certificatesDeactivated(
                            AuditLogListResponse.CertificatesDeactivated.builder()
                                .addCertificate(
                                    AuditLogListResponse.CertificatesDeactivated.Certificate
                                        .builder()
                                        .id("id")
                                        .name("name")
                                        .build()
                                )
                                .build()
                        )
                        .checkpointPermissionCreated(
                            AuditLogListResponse.CheckpointPermissionCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.CheckpointPermissionCreated.Data.builder()
                                        .fineTunedModelCheckpoint("fine_tuned_model_checkpoint")
                                        .projectId("project_id")
                                        .build()
                                )
                                .build()
                        )
                        .checkpointPermissionDeleted(
                            AuditLogListResponse.CheckpointPermissionDeleted.builder()
                                .id("id")
                                .build()
                        )
                        .externalKeyRegistered(
                            AuditLogListResponse.ExternalKeyRegistered.builder()
                                .id("id")
                                .data(JsonValue.from(mapOf<String, Any>()))
                                .build()
                        )
                        .externalKeyRemoved(
                            AuditLogListResponse.ExternalKeyRemoved.builder().id("id").build()
                        )
                        .groupCreated(
                            AuditLogListResponse.GroupCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.GroupCreated.Data.builder()
                                        .groupName("group_name")
                                        .build()
                                )
                                .build()
                        )
                        .groupDeleted(AuditLogListResponse.GroupDeleted.builder().id("id").build())
                        .groupUpdated(
                            AuditLogListResponse.GroupUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.GroupUpdated.ChangesRequested.builder()
                                        .groupName("group_name")
                                        .build()
                                )
                                .build()
                        )
                        .inviteAccepted(
                            AuditLogListResponse.InviteAccepted.builder().id("id").build()
                        )
                        .inviteDeleted(
                            AuditLogListResponse.InviteDeleted.builder().id("id").build()
                        )
                        .inviteSent(
                            AuditLogListResponse.InviteSent.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.InviteSent.Data.builder()
                                        .email("email")
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .ipAllowlistConfigActivated(
                            AuditLogListResponse.IpAllowlistConfigActivated.builder()
                                .addConfig(
                                    AuditLogListResponse.IpAllowlistConfigActivated.Config.builder()
                                        .id("id")
                                        .name("name")
                                        .build()
                                )
                                .build()
                        )
                        .ipAllowlistConfigDeactivated(
                            AuditLogListResponse.IpAllowlistConfigDeactivated.builder()
                                .addConfig(
                                    AuditLogListResponse.IpAllowlistConfigDeactivated.Config
                                        .builder()
                                        .id("id")
                                        .name("name")
                                        .build()
                                )
                                .build()
                        )
                        .ipAllowlistCreated(
                            AuditLogListResponse.IpAllowlistCreated.builder()
                                .id("id")
                                .addAllowedIp("string")
                                .name("name")
                                .build()
                        )
                        .ipAllowlistDeleted(
                            AuditLogListResponse.IpAllowlistDeleted.builder()
                                .id("id")
                                .addAllowedIp("string")
                                .name("name")
                                .build()
                        )
                        .ipAllowlistUpdated(
                            AuditLogListResponse.IpAllowlistUpdated.builder()
                                .id("id")
                                .addAllowedIp("string")
                                .build()
                        )
                        .loginFailed(
                            AuditLogListResponse.LoginFailed.builder()
                                .errorCode("error_code")
                                .errorMessage("error_message")
                                .build()
                        )
                        .loginSucceeded(JsonValue.from(mapOf<String, Any>()))
                        .logoutFailed(
                            AuditLogListResponse.LogoutFailed.builder()
                                .errorCode("error_code")
                                .errorMessage("error_message")
                                .build()
                        )
                        .logoutSucceeded(JsonValue.from(mapOf<String, Any>()))
                        .organizationUpdated(
                            AuditLogListResponse.OrganizationUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.OrganizationUpdated.ChangesRequested
                                        .builder()
                                        .apiCallLogging("api_call_logging")
                                        .apiCallLoggingProjectIds("api_call_logging_project_ids")
                                        .description("description")
                                        .name("name")
                                        .threadsUiVisibility("threads_ui_visibility")
                                        .title("title")
                                        .usageDashboardVisibility("usage_dashboard_visibility")
                                        .build()
                                )
                                .build()
                        )
                        .project(
                            AuditLogListResponse.Project.builder().id("id").name("name").build()
                        )
                        .projectArchived(
                            AuditLogListResponse.ProjectArchived.builder().id("id").build()
                        )
                        .projectCreated(
                            AuditLogListResponse.ProjectCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.ProjectCreated.Data.builder()
                                        .name("name")
                                        .title("title")
                                        .build()
                                )
                                .build()
                        )
                        .projectDeleted(
                            AuditLogListResponse.ProjectDeleted.builder().id("id").build()
                        )
                        .projectUpdated(
                            AuditLogListResponse.ProjectUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.ProjectUpdated.ChangesRequested.builder()
                                        .title("title")
                                        .build()
                                )
                                .build()
                        )
                        .rateLimitDeleted(
                            AuditLogListResponse.RateLimitDeleted.builder().id("id").build()
                        )
                        .rateLimitUpdated(
                            AuditLogListResponse.RateLimitUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.RateLimitUpdated.ChangesRequested.builder()
                                        .batch1DayMaxInputTokens(0L)
                                        .maxAudioMegabytesPer1Minute(0L)
                                        .maxImagesPer1Minute(0L)
                                        .maxRequestsPer1Day(0L)
                                        .maxRequestsPer1Minute(0L)
                                        .maxTokensPer1Minute(0L)
                                        .build()
                                )
                                .build()
                        )
                        .roleAssignmentCreated(
                            AuditLogListResponse.RoleAssignmentCreated.builder()
                                .id("id")
                                .principalId("principal_id")
                                .principalType("principal_type")
                                .resourceId("resource_id")
                                .resourceType("resource_type")
                                .build()
                        )
                        .roleAssignmentDeleted(
                            AuditLogListResponse.RoleAssignmentDeleted.builder()
                                .id("id")
                                .principalId("principal_id")
                                .principalType("principal_type")
                                .resourceId("resource_id")
                                .resourceType("resource_type")
                                .build()
                        )
                        .roleCreated(
                            AuditLogListResponse.RoleCreated.builder()
                                .id("id")
                                .addPermission("string")
                                .resourceId("resource_id")
                                .resourceType("resource_type")
                                .roleName("role_name")
                                .build()
                        )
                        .roleDeleted(AuditLogListResponse.RoleDeleted.builder().id("id").build())
                        .roleUpdated(
                            AuditLogListResponse.RoleUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.RoleUpdated.ChangesRequested.builder()
                                        .description("description")
                                        .metadata(JsonValue.from(mapOf<String, Any>()))
                                        .addPermissionsAdded("string")
                                        .addPermissionsRemoved("string")
                                        .resourceId("resource_id")
                                        .resourceType("resource_type")
                                        .roleName("role_name")
                                        .build()
                                )
                                .build()
                        )
                        .scimDisabled(AuditLogListResponse.ScimDisabled.builder().id("id").build())
                        .scimEnabled(AuditLogListResponse.ScimEnabled.builder().id("id").build())
                        .serviceAccountCreated(
                            AuditLogListResponse.ServiceAccountCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.ServiceAccountCreated.Data.builder()
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .serviceAccountDeleted(
                            AuditLogListResponse.ServiceAccountDeleted.builder().id("id").build()
                        )
                        .serviceAccountUpdated(
                            AuditLogListResponse.ServiceAccountUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.ServiceAccountUpdated.ChangesRequested
                                        .builder()
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .userAdded(
                            AuditLogListResponse.UserAdded.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.UserAdded.Data.builder()
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .userDeleted(AuditLogListResponse.UserDeleted.builder().id("id").build())
                        .userUpdated(
                            AuditLogListResponse.UserUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.UserUpdated.ChangesRequested.builder()
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .workloadIdentityProviderMappingCreated(
                            AuditLogListResponse.WorkloadIdentityProviderMappingCreated.builder()
                                .id("id")
                                .data(JsonValue.from(mapOf<String, Any>()))
                                .identityProviderId("identity_provider_id")
                                .build()
                        )
                        .workloadIdentityProviderMappingDeleted(
                            AuditLogListResponse.WorkloadIdentityProviderMappingDeleted.builder()
                                .id("id")
                                .identityProviderId("identity_provider_id")
                                .projectId("project_id")
                                .serviceAccountId("service_account_id")
                                .build()
                        )
                        .workloadIdentityProviderMappingUpdated(
                            AuditLogListResponse.WorkloadIdentityProviderMappingUpdated.builder()
                                .id("id")
                                .changesRequested(JsonValue.from(mapOf<String, Any>()))
                                .identityProviderId("identity_provider_id")
                                .build()
                        )
                        .workloadIdentityProviderCreated(
                            AuditLogListResponse.WorkloadIdentityProviderCreated.builder()
                                .id("id")
                                .data(JsonValue.from(mapOf<String, Any>()))
                                .build()
                        )
                        .workloadIdentityProviderDeleted(
                            AuditLogListResponse.WorkloadIdentityProviderDeleted.builder()
                                .id("id")
                                .name("name")
                                .build()
                        )
                        .workloadIdentityProviderUpdated(
                            AuditLogListResponse.WorkloadIdentityProviderUpdated.builder()
                                .id("id")
                                .changesRequested(JsonValue.from(mapOf<String, Any>()))
                                .build()
                        )
                        .build()
                )
                .hasMore(true)
                .firstId("audit_log-defb456h8dks")
                .lastId("audit_log-hnbkd8s93s")
                .build()

        assertThat(auditLogListPageResponse.data())
            .containsExactly(
                AuditLogListResponse.builder()
                    .id("id")
                    .effectiveAt(0L)
                    .type(AuditLogListResponse.Type.API_KEY_CREATED)
                    .actor(
                        AuditLogListResponse.Actor.builder()
                            .apiKey(
                                AuditLogListResponse.Actor.ApiKey.builder()
                                    .id("id")
                                    .serviceAccount(
                                        AuditLogListResponse.Actor.ApiKey.ServiceAccount.builder()
                                            .id("id")
                                            .build()
                                    )
                                    .type(AuditLogListResponse.Actor.ApiKey.Type.USER)
                                    .user(
                                        AuditLogListResponse.Actor.ApiKey.User.builder()
                                            .id("id")
                                            .email("email")
                                            .build()
                                    )
                                    .build()
                            )
                            .session(
                                AuditLogListResponse.Actor.Session.builder()
                                    .ipAddress("ip_address")
                                    .user(
                                        AuditLogListResponse.Actor.Session.User.builder()
                                            .id("id")
                                            .email("email")
                                            .build()
                                    )
                                    .build()
                            )
                            .type(AuditLogListResponse.Actor.Type.SESSION)
                            .build()
                    )
                    .apiKeyCreated(
                        AuditLogListResponse.ApiKeyCreated.builder()
                            .id("id")
                            .data(
                                AuditLogListResponse.ApiKeyCreated.Data.builder()
                                    .addScope("string")
                                    .build()
                            )
                            .build()
                    )
                    .apiKeyDeleted(AuditLogListResponse.ApiKeyDeleted.builder().id("id").build())
                    .apiKeyUpdated(
                        AuditLogListResponse.ApiKeyUpdated.builder()
                            .id("id")
                            .changesRequested(
                                AuditLogListResponse.ApiKeyUpdated.ChangesRequested.builder()
                                    .addScope("string")
                                    .build()
                            )
                            .build()
                    )
                    .certificateCreated(
                        AuditLogListResponse.CertificateCreated.builder()
                            .id("id")
                            .name("name")
                            .build()
                    )
                    .certificateDeleted(
                        AuditLogListResponse.CertificateDeleted.builder()
                            .id("id")
                            .certificate("certificate")
                            .name("name")
                            .build()
                    )
                    .certificateUpdated(
                        AuditLogListResponse.CertificateUpdated.builder()
                            .id("id")
                            .name("name")
                            .build()
                    )
                    .certificatesActivated(
                        AuditLogListResponse.CertificatesActivated.builder()
                            .addCertificate(
                                AuditLogListResponse.CertificatesActivated.Certificate.builder()
                                    .id("id")
                                    .name("name")
                                    .build()
                            )
                            .build()
                    )
                    .certificatesDeactivated(
                        AuditLogListResponse.CertificatesDeactivated.builder()
                            .addCertificate(
                                AuditLogListResponse.CertificatesDeactivated.Certificate.builder()
                                    .id("id")
                                    .name("name")
                                    .build()
                            )
                            .build()
                    )
                    .checkpointPermissionCreated(
                        AuditLogListResponse.CheckpointPermissionCreated.builder()
                            .id("id")
                            .data(
                                AuditLogListResponse.CheckpointPermissionCreated.Data.builder()
                                    .fineTunedModelCheckpoint("fine_tuned_model_checkpoint")
                                    .projectId("project_id")
                                    .build()
                            )
                            .build()
                    )
                    .checkpointPermissionDeleted(
                        AuditLogListResponse.CheckpointPermissionDeleted.builder().id("id").build()
                    )
                    .externalKeyRegistered(
                        AuditLogListResponse.ExternalKeyRegistered.builder()
                            .id("id")
                            .data(JsonValue.from(mapOf<String, Any>()))
                            .build()
                    )
                    .externalKeyRemoved(
                        AuditLogListResponse.ExternalKeyRemoved.builder().id("id").build()
                    )
                    .groupCreated(
                        AuditLogListResponse.GroupCreated.builder()
                            .id("id")
                            .data(
                                AuditLogListResponse.GroupCreated.Data.builder()
                                    .groupName("group_name")
                                    .build()
                            )
                            .build()
                    )
                    .groupDeleted(AuditLogListResponse.GroupDeleted.builder().id("id").build())
                    .groupUpdated(
                        AuditLogListResponse.GroupUpdated.builder()
                            .id("id")
                            .changesRequested(
                                AuditLogListResponse.GroupUpdated.ChangesRequested.builder()
                                    .groupName("group_name")
                                    .build()
                            )
                            .build()
                    )
                    .inviteAccepted(AuditLogListResponse.InviteAccepted.builder().id("id").build())
                    .inviteDeleted(AuditLogListResponse.InviteDeleted.builder().id("id").build())
                    .inviteSent(
                        AuditLogListResponse.InviteSent.builder()
                            .id("id")
                            .data(
                                AuditLogListResponse.InviteSent.Data.builder()
                                    .email("email")
                                    .role("role")
                                    .build()
                            )
                            .build()
                    )
                    .ipAllowlistConfigActivated(
                        AuditLogListResponse.IpAllowlistConfigActivated.builder()
                            .addConfig(
                                AuditLogListResponse.IpAllowlistConfigActivated.Config.builder()
                                    .id("id")
                                    .name("name")
                                    .build()
                            )
                            .build()
                    )
                    .ipAllowlistConfigDeactivated(
                        AuditLogListResponse.IpAllowlistConfigDeactivated.builder()
                            .addConfig(
                                AuditLogListResponse.IpAllowlistConfigDeactivated.Config.builder()
                                    .id("id")
                                    .name("name")
                                    .build()
                            )
                            .build()
                    )
                    .ipAllowlistCreated(
                        AuditLogListResponse.IpAllowlistCreated.builder()
                            .id("id")
                            .addAllowedIp("string")
                            .name("name")
                            .build()
                    )
                    .ipAllowlistDeleted(
                        AuditLogListResponse.IpAllowlistDeleted.builder()
                            .id("id")
                            .addAllowedIp("string")
                            .name("name")
                            .build()
                    )
                    .ipAllowlistUpdated(
                        AuditLogListResponse.IpAllowlistUpdated.builder()
                            .id("id")
                            .addAllowedIp("string")
                            .build()
                    )
                    .loginFailed(
                        AuditLogListResponse.LoginFailed.builder()
                            .errorCode("error_code")
                            .errorMessage("error_message")
                            .build()
                    )
                    .loginSucceeded(JsonValue.from(mapOf<String, Any>()))
                    .logoutFailed(
                        AuditLogListResponse.LogoutFailed.builder()
                            .errorCode("error_code")
                            .errorMessage("error_message")
                            .build()
                    )
                    .logoutSucceeded(JsonValue.from(mapOf<String, Any>()))
                    .organizationUpdated(
                        AuditLogListResponse.OrganizationUpdated.builder()
                            .id("id")
                            .changesRequested(
                                AuditLogListResponse.OrganizationUpdated.ChangesRequested.builder()
                                    .apiCallLogging("api_call_logging")
                                    .apiCallLoggingProjectIds("api_call_logging_project_ids")
                                    .description("description")
                                    .name("name")
                                    .threadsUiVisibility("threads_ui_visibility")
                                    .title("title")
                                    .usageDashboardVisibility("usage_dashboard_visibility")
                                    .build()
                            )
                            .build()
                    )
                    .project(AuditLogListResponse.Project.builder().id("id").name("name").build())
                    .projectArchived(
                        AuditLogListResponse.ProjectArchived.builder().id("id").build()
                    )
                    .projectCreated(
                        AuditLogListResponse.ProjectCreated.builder()
                            .id("id")
                            .data(
                                AuditLogListResponse.ProjectCreated.Data.builder()
                                    .name("name")
                                    .title("title")
                                    .build()
                            )
                            .build()
                    )
                    .projectDeleted(AuditLogListResponse.ProjectDeleted.builder().id("id").build())
                    .projectUpdated(
                        AuditLogListResponse.ProjectUpdated.builder()
                            .id("id")
                            .changesRequested(
                                AuditLogListResponse.ProjectUpdated.ChangesRequested.builder()
                                    .title("title")
                                    .build()
                            )
                            .build()
                    )
                    .rateLimitDeleted(
                        AuditLogListResponse.RateLimitDeleted.builder().id("id").build()
                    )
                    .rateLimitUpdated(
                        AuditLogListResponse.RateLimitUpdated.builder()
                            .id("id")
                            .changesRequested(
                                AuditLogListResponse.RateLimitUpdated.ChangesRequested.builder()
                                    .batch1DayMaxInputTokens(0L)
                                    .maxAudioMegabytesPer1Minute(0L)
                                    .maxImagesPer1Minute(0L)
                                    .maxRequestsPer1Day(0L)
                                    .maxRequestsPer1Minute(0L)
                                    .maxTokensPer1Minute(0L)
                                    .build()
                            )
                            .build()
                    )
                    .roleAssignmentCreated(
                        AuditLogListResponse.RoleAssignmentCreated.builder()
                            .id("id")
                            .principalId("principal_id")
                            .principalType("principal_type")
                            .resourceId("resource_id")
                            .resourceType("resource_type")
                            .build()
                    )
                    .roleAssignmentDeleted(
                        AuditLogListResponse.RoleAssignmentDeleted.builder()
                            .id("id")
                            .principalId("principal_id")
                            .principalType("principal_type")
                            .resourceId("resource_id")
                            .resourceType("resource_type")
                            .build()
                    )
                    .roleCreated(
                        AuditLogListResponse.RoleCreated.builder()
                            .id("id")
                            .addPermission("string")
                            .resourceId("resource_id")
                            .resourceType("resource_type")
                            .roleName("role_name")
                            .build()
                    )
                    .roleDeleted(AuditLogListResponse.RoleDeleted.builder().id("id").build())
                    .roleUpdated(
                        AuditLogListResponse.RoleUpdated.builder()
                            .id("id")
                            .changesRequested(
                                AuditLogListResponse.RoleUpdated.ChangesRequested.builder()
                                    .description("description")
                                    .metadata(JsonValue.from(mapOf<String, Any>()))
                                    .addPermissionsAdded("string")
                                    .addPermissionsRemoved("string")
                                    .resourceId("resource_id")
                                    .resourceType("resource_type")
                                    .roleName("role_name")
                                    .build()
                            )
                            .build()
                    )
                    .scimDisabled(AuditLogListResponse.ScimDisabled.builder().id("id").build())
                    .scimEnabled(AuditLogListResponse.ScimEnabled.builder().id("id").build())
                    .serviceAccountCreated(
                        AuditLogListResponse.ServiceAccountCreated.builder()
                            .id("id")
                            .data(
                                AuditLogListResponse.ServiceAccountCreated.Data.builder()
                                    .role("role")
                                    .build()
                            )
                            .build()
                    )
                    .serviceAccountDeleted(
                        AuditLogListResponse.ServiceAccountDeleted.builder().id("id").build()
                    )
                    .serviceAccountUpdated(
                        AuditLogListResponse.ServiceAccountUpdated.builder()
                            .id("id")
                            .changesRequested(
                                AuditLogListResponse.ServiceAccountUpdated.ChangesRequested
                                    .builder()
                                    .role("role")
                                    .build()
                            )
                            .build()
                    )
                    .userAdded(
                        AuditLogListResponse.UserAdded.builder()
                            .id("id")
                            .data(
                                AuditLogListResponse.UserAdded.Data.builder().role("role").build()
                            )
                            .build()
                    )
                    .userDeleted(AuditLogListResponse.UserDeleted.builder().id("id").build())
                    .userUpdated(
                        AuditLogListResponse.UserUpdated.builder()
                            .id("id")
                            .changesRequested(
                                AuditLogListResponse.UserUpdated.ChangesRequested.builder()
                                    .role("role")
                                    .build()
                            )
                            .build()
                    )
                    .workloadIdentityProviderMappingCreated(
                        AuditLogListResponse.WorkloadIdentityProviderMappingCreated.builder()
                            .id("id")
                            .data(JsonValue.from(mapOf<String, Any>()))
                            .identityProviderId("identity_provider_id")
                            .build()
                    )
                    .workloadIdentityProviderMappingDeleted(
                        AuditLogListResponse.WorkloadIdentityProviderMappingDeleted.builder()
                            .id("id")
                            .identityProviderId("identity_provider_id")
                            .projectId("project_id")
                            .serviceAccountId("service_account_id")
                            .build()
                    )
                    .workloadIdentityProviderMappingUpdated(
                        AuditLogListResponse.WorkloadIdentityProviderMappingUpdated.builder()
                            .id("id")
                            .changesRequested(JsonValue.from(mapOf<String, Any>()))
                            .identityProviderId("identity_provider_id")
                            .build()
                    )
                    .workloadIdentityProviderCreated(
                        AuditLogListResponse.WorkloadIdentityProviderCreated.builder()
                            .id("id")
                            .data(JsonValue.from(mapOf<String, Any>()))
                            .build()
                    )
                    .workloadIdentityProviderDeleted(
                        AuditLogListResponse.WorkloadIdentityProviderDeleted.builder()
                            .id("id")
                            .name("name")
                            .build()
                    )
                    .workloadIdentityProviderUpdated(
                        AuditLogListResponse.WorkloadIdentityProviderUpdated.builder()
                            .id("id")
                            .changesRequested(JsonValue.from(mapOf<String, Any>()))
                            .build()
                    )
                    .build()
            )
        assertThat(auditLogListPageResponse.hasMore()).isEqualTo(true)
        assertThat(auditLogListPageResponse.firstId()).contains("audit_log-defb456h8dks")
        assertThat(auditLogListPageResponse.lastId()).contains("audit_log-hnbkd8s93s")
    }

    @Test
    fun roundtrip() {
        val jsonMapper = jsonMapper()
        val auditLogListPageResponse =
            AuditLogListPageResponse.builder()
                .addData(
                    AuditLogListResponse.builder()
                        .id("id")
                        .effectiveAt(0L)
                        .type(AuditLogListResponse.Type.API_KEY_CREATED)
                        .actor(
                            AuditLogListResponse.Actor.builder()
                                .apiKey(
                                    AuditLogListResponse.Actor.ApiKey.builder()
                                        .id("id")
                                        .serviceAccount(
                                            AuditLogListResponse.Actor.ApiKey.ServiceAccount
                                                .builder()
                                                .id("id")
                                                .build()
                                        )
                                        .type(AuditLogListResponse.Actor.ApiKey.Type.USER)
                                        .user(
                                            AuditLogListResponse.Actor.ApiKey.User.builder()
                                                .id("id")
                                                .email("email")
                                                .build()
                                        )
                                        .build()
                                )
                                .session(
                                    AuditLogListResponse.Actor.Session.builder()
                                        .ipAddress("ip_address")
                                        .user(
                                            AuditLogListResponse.Actor.Session.User.builder()
                                                .id("id")
                                                .email("email")
                                                .build()
                                        )
                                        .build()
                                )
                                .type(AuditLogListResponse.Actor.Type.SESSION)
                                .build()
                        )
                        .apiKeyCreated(
                            AuditLogListResponse.ApiKeyCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.ApiKeyCreated.Data.builder()
                                        .addScope("string")
                                        .build()
                                )
                                .build()
                        )
                        .apiKeyDeleted(
                            AuditLogListResponse.ApiKeyDeleted.builder().id("id").build()
                        )
                        .apiKeyUpdated(
                            AuditLogListResponse.ApiKeyUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.ApiKeyUpdated.ChangesRequested.builder()
                                        .addScope("string")
                                        .build()
                                )
                                .build()
                        )
                        .certificateCreated(
                            AuditLogListResponse.CertificateCreated.builder()
                                .id("id")
                                .name("name")
                                .build()
                        )
                        .certificateDeleted(
                            AuditLogListResponse.CertificateDeleted.builder()
                                .id("id")
                                .certificate("certificate")
                                .name("name")
                                .build()
                        )
                        .certificateUpdated(
                            AuditLogListResponse.CertificateUpdated.builder()
                                .id("id")
                                .name("name")
                                .build()
                        )
                        .certificatesActivated(
                            AuditLogListResponse.CertificatesActivated.builder()
                                .addCertificate(
                                    AuditLogListResponse.CertificatesActivated.Certificate.builder()
                                        .id("id")
                                        .name("name")
                                        .build()
                                )
                                .build()
                        )
                        .certificatesDeactivated(
                            AuditLogListResponse.CertificatesDeactivated.builder()
                                .addCertificate(
                                    AuditLogListResponse.CertificatesDeactivated.Certificate
                                        .builder()
                                        .id("id")
                                        .name("name")
                                        .build()
                                )
                                .build()
                        )
                        .checkpointPermissionCreated(
                            AuditLogListResponse.CheckpointPermissionCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.CheckpointPermissionCreated.Data.builder()
                                        .fineTunedModelCheckpoint("fine_tuned_model_checkpoint")
                                        .projectId("project_id")
                                        .build()
                                )
                                .build()
                        )
                        .checkpointPermissionDeleted(
                            AuditLogListResponse.CheckpointPermissionDeleted.builder()
                                .id("id")
                                .build()
                        )
                        .externalKeyRegistered(
                            AuditLogListResponse.ExternalKeyRegistered.builder()
                                .id("id")
                                .data(JsonValue.from(mapOf<String, Any>()))
                                .build()
                        )
                        .externalKeyRemoved(
                            AuditLogListResponse.ExternalKeyRemoved.builder().id("id").build()
                        )
                        .groupCreated(
                            AuditLogListResponse.GroupCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.GroupCreated.Data.builder()
                                        .groupName("group_name")
                                        .build()
                                )
                                .build()
                        )
                        .groupDeleted(AuditLogListResponse.GroupDeleted.builder().id("id").build())
                        .groupUpdated(
                            AuditLogListResponse.GroupUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.GroupUpdated.ChangesRequested.builder()
                                        .groupName("group_name")
                                        .build()
                                )
                                .build()
                        )
                        .inviteAccepted(
                            AuditLogListResponse.InviteAccepted.builder().id("id").build()
                        )
                        .inviteDeleted(
                            AuditLogListResponse.InviteDeleted.builder().id("id").build()
                        )
                        .inviteSent(
                            AuditLogListResponse.InviteSent.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.InviteSent.Data.builder()
                                        .email("email")
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .ipAllowlistConfigActivated(
                            AuditLogListResponse.IpAllowlistConfigActivated.builder()
                                .addConfig(
                                    AuditLogListResponse.IpAllowlistConfigActivated.Config.builder()
                                        .id("id")
                                        .name("name")
                                        .build()
                                )
                                .build()
                        )
                        .ipAllowlistConfigDeactivated(
                            AuditLogListResponse.IpAllowlistConfigDeactivated.builder()
                                .addConfig(
                                    AuditLogListResponse.IpAllowlistConfigDeactivated.Config
                                        .builder()
                                        .id("id")
                                        .name("name")
                                        .build()
                                )
                                .build()
                        )
                        .ipAllowlistCreated(
                            AuditLogListResponse.IpAllowlistCreated.builder()
                                .id("id")
                                .addAllowedIp("string")
                                .name("name")
                                .build()
                        )
                        .ipAllowlistDeleted(
                            AuditLogListResponse.IpAllowlistDeleted.builder()
                                .id("id")
                                .addAllowedIp("string")
                                .name("name")
                                .build()
                        )
                        .ipAllowlistUpdated(
                            AuditLogListResponse.IpAllowlistUpdated.builder()
                                .id("id")
                                .addAllowedIp("string")
                                .build()
                        )
                        .loginFailed(
                            AuditLogListResponse.LoginFailed.builder()
                                .errorCode("error_code")
                                .errorMessage("error_message")
                                .build()
                        )
                        .loginSucceeded(JsonValue.from(mapOf<String, Any>()))
                        .logoutFailed(
                            AuditLogListResponse.LogoutFailed.builder()
                                .errorCode("error_code")
                                .errorMessage("error_message")
                                .build()
                        )
                        .logoutSucceeded(JsonValue.from(mapOf<String, Any>()))
                        .organizationUpdated(
                            AuditLogListResponse.OrganizationUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.OrganizationUpdated.ChangesRequested
                                        .builder()
                                        .apiCallLogging("api_call_logging")
                                        .apiCallLoggingProjectIds("api_call_logging_project_ids")
                                        .description("description")
                                        .name("name")
                                        .threadsUiVisibility("threads_ui_visibility")
                                        .title("title")
                                        .usageDashboardVisibility("usage_dashboard_visibility")
                                        .build()
                                )
                                .build()
                        )
                        .project(
                            AuditLogListResponse.Project.builder().id("id").name("name").build()
                        )
                        .projectArchived(
                            AuditLogListResponse.ProjectArchived.builder().id("id").build()
                        )
                        .projectCreated(
                            AuditLogListResponse.ProjectCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.ProjectCreated.Data.builder()
                                        .name("name")
                                        .title("title")
                                        .build()
                                )
                                .build()
                        )
                        .projectDeleted(
                            AuditLogListResponse.ProjectDeleted.builder().id("id").build()
                        )
                        .projectUpdated(
                            AuditLogListResponse.ProjectUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.ProjectUpdated.ChangesRequested.builder()
                                        .title("title")
                                        .build()
                                )
                                .build()
                        )
                        .rateLimitDeleted(
                            AuditLogListResponse.RateLimitDeleted.builder().id("id").build()
                        )
                        .rateLimitUpdated(
                            AuditLogListResponse.RateLimitUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.RateLimitUpdated.ChangesRequested.builder()
                                        .batch1DayMaxInputTokens(0L)
                                        .maxAudioMegabytesPer1Minute(0L)
                                        .maxImagesPer1Minute(0L)
                                        .maxRequestsPer1Day(0L)
                                        .maxRequestsPer1Minute(0L)
                                        .maxTokensPer1Minute(0L)
                                        .build()
                                )
                                .build()
                        )
                        .roleAssignmentCreated(
                            AuditLogListResponse.RoleAssignmentCreated.builder()
                                .id("id")
                                .principalId("principal_id")
                                .principalType("principal_type")
                                .resourceId("resource_id")
                                .resourceType("resource_type")
                                .build()
                        )
                        .roleAssignmentDeleted(
                            AuditLogListResponse.RoleAssignmentDeleted.builder()
                                .id("id")
                                .principalId("principal_id")
                                .principalType("principal_type")
                                .resourceId("resource_id")
                                .resourceType("resource_type")
                                .build()
                        )
                        .roleCreated(
                            AuditLogListResponse.RoleCreated.builder()
                                .id("id")
                                .addPermission("string")
                                .resourceId("resource_id")
                                .resourceType("resource_type")
                                .roleName("role_name")
                                .build()
                        )
                        .roleDeleted(AuditLogListResponse.RoleDeleted.builder().id("id").build())
                        .roleUpdated(
                            AuditLogListResponse.RoleUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.RoleUpdated.ChangesRequested.builder()
                                        .description("description")
                                        .metadata(JsonValue.from(mapOf<String, Any>()))
                                        .addPermissionsAdded("string")
                                        .addPermissionsRemoved("string")
                                        .resourceId("resource_id")
                                        .resourceType("resource_type")
                                        .roleName("role_name")
                                        .build()
                                )
                                .build()
                        )
                        .scimDisabled(AuditLogListResponse.ScimDisabled.builder().id("id").build())
                        .scimEnabled(AuditLogListResponse.ScimEnabled.builder().id("id").build())
                        .serviceAccountCreated(
                            AuditLogListResponse.ServiceAccountCreated.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.ServiceAccountCreated.Data.builder()
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .serviceAccountDeleted(
                            AuditLogListResponse.ServiceAccountDeleted.builder().id("id").build()
                        )
                        .serviceAccountUpdated(
                            AuditLogListResponse.ServiceAccountUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.ServiceAccountUpdated.ChangesRequested
                                        .builder()
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .userAdded(
                            AuditLogListResponse.UserAdded.builder()
                                .id("id")
                                .data(
                                    AuditLogListResponse.UserAdded.Data.builder()
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .userDeleted(AuditLogListResponse.UserDeleted.builder().id("id").build())
                        .userUpdated(
                            AuditLogListResponse.UserUpdated.builder()
                                .id("id")
                                .changesRequested(
                                    AuditLogListResponse.UserUpdated.ChangesRequested.builder()
                                        .role("role")
                                        .build()
                                )
                                .build()
                        )
                        .workloadIdentityProviderMappingCreated(
                            AuditLogListResponse.WorkloadIdentityProviderMappingCreated.builder()
                                .id("id")
                                .data(JsonValue.from(mapOf<String, Any>()))
                                .identityProviderId("identity_provider_id")
                                .build()
                        )
                        .workloadIdentityProviderMappingDeleted(
                            AuditLogListResponse.WorkloadIdentityProviderMappingDeleted.builder()
                                .id("id")
                                .identityProviderId("identity_provider_id")
                                .projectId("project_id")
                                .serviceAccountId("service_account_id")
                                .build()
                        )
                        .workloadIdentityProviderMappingUpdated(
                            AuditLogListResponse.WorkloadIdentityProviderMappingUpdated.builder()
                                .id("id")
                                .changesRequested(JsonValue.from(mapOf<String, Any>()))
                                .identityProviderId("identity_provider_id")
                                .build()
                        )
                        .workloadIdentityProviderCreated(
                            AuditLogListResponse.WorkloadIdentityProviderCreated.builder()
                                .id("id")
                                .data(JsonValue.from(mapOf<String, Any>()))
                                .build()
                        )
                        .workloadIdentityProviderDeleted(
                            AuditLogListResponse.WorkloadIdentityProviderDeleted.builder()
                                .id("id")
                                .name("name")
                                .build()
                        )
                        .workloadIdentityProviderUpdated(
                            AuditLogListResponse.WorkloadIdentityProviderUpdated.builder()
                                .id("id")
                                .changesRequested(JsonValue.from(mapOf<String, Any>()))
                                .build()
                        )
                        .build()
                )
                .hasMore(true)
                .firstId("audit_log-defb456h8dks")
                .lastId("audit_log-hnbkd8s93s")
                .build()

        val roundtrippedAuditLogListPageResponse =
            jsonMapper.readValue(
                jsonMapper.writeValueAsString(auditLogListPageResponse),
                jacksonTypeRef<AuditLogListPageResponse>(),
            )

        assertThat(roundtrippedAuditLogListPageResponse).isEqualTo(auditLogListPageResponse)
    }
}
