/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2025.10.0-rc1
 * Contact: hello@goauthentik.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import { mapValues } from '../runtime';
import type { CountryCodeEnum } from './CountryCodeEnum';
import {
    CountryCodeEnumFromJSON,
    CountryCodeEnumFromJSONTyped,
    CountryCodeEnumToJSON,
    CountryCodeEnumToJSONTyped,
} from './CountryCodeEnum';

/**
 * GeoIP Policy Serializer
 * @export
 * @interface GeoIPPolicyRequest
 */
export interface GeoIPPolicyRequest {
    /**
     * 
     * @type {string}
     * @memberof GeoIPPolicyRequest
     */
    name: string;
    /**
     * When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged.
     * @type {boolean}
     * @memberof GeoIPPolicyRequest
     */
    executionLogging?: boolean;
    /**
     * 
     * @type {Array<number>}
     * @memberof GeoIPPolicyRequest
     */
    asns?: Array<number>;
    /**
     * 
     * @type {Array<CountryCodeEnum>}
     * @memberof GeoIPPolicyRequest
     */
    countries: Array<CountryCodeEnum>;
    /**
     * 
     * @type {boolean}
     * @memberof GeoIPPolicyRequest
     */
    checkHistoryDistance?: boolean;
    /**
     * 
     * @type {number}
     * @memberof GeoIPPolicyRequest
     */
    historyMaxDistanceKm?: number;
    /**
     * 
     * @type {number}
     * @memberof GeoIPPolicyRequest
     */
    distanceToleranceKm?: number;
    /**
     * 
     * @type {number}
     * @memberof GeoIPPolicyRequest
     */
    historyLoginCount?: number;
    /**
     * 
     * @type {boolean}
     * @memberof GeoIPPolicyRequest
     */
    checkImpossibleTravel?: boolean;
    /**
     * 
     * @type {number}
     * @memberof GeoIPPolicyRequest
     */
    impossibleToleranceKm?: number;
}

/**
 * Check if a given object implements the GeoIPPolicyRequest interface.
 */
export function instanceOfGeoIPPolicyRequest(value: object): value is GeoIPPolicyRequest {
    if (!('name' in value) || value['name'] === undefined) return false;
    if (!('countries' in value) || value['countries'] === undefined) return false;
    return true;
}

export function GeoIPPolicyRequestFromJSON(json: any): GeoIPPolicyRequest {
    return GeoIPPolicyRequestFromJSONTyped(json, false);
}

export function GeoIPPolicyRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): GeoIPPolicyRequest {
    if (json == null) {
        return json;
    }
    return {
        
        'name': json['name'],
        'executionLogging': json['execution_logging'] == null ? undefined : json['execution_logging'],
        'asns': json['asns'] == null ? undefined : json['asns'],
        'countries': ((json['countries'] as Array<any>).map(CountryCodeEnumFromJSON)),
        'checkHistoryDistance': json['check_history_distance'] == null ? undefined : json['check_history_distance'],
        'historyMaxDistanceKm': json['history_max_distance_km'] == null ? undefined : json['history_max_distance_km'],
        'distanceToleranceKm': json['distance_tolerance_km'] == null ? undefined : json['distance_tolerance_km'],
        'historyLoginCount': json['history_login_count'] == null ? undefined : json['history_login_count'],
        'checkImpossibleTravel': json['check_impossible_travel'] == null ? undefined : json['check_impossible_travel'],
        'impossibleToleranceKm': json['impossible_tolerance_km'] == null ? undefined : json['impossible_tolerance_km'],
    };
}

export function GeoIPPolicyRequestToJSON(json: any): GeoIPPolicyRequest {
    return GeoIPPolicyRequestToJSONTyped(json, false);
}

export function GeoIPPolicyRequestToJSONTyped(value?: GeoIPPolicyRequest | null, ignoreDiscriminator: boolean = false): any {
    if (value == null) {
        return value;
    }

    return {
        
        'name': value['name'],
        'execution_logging': value['executionLogging'],
        'asns': value['asns'],
        'countries': ((value['countries'] as Array<any>).map(CountryCodeEnumToJSON)),
        'check_history_distance': value['checkHistoryDistance'],
        'history_max_distance_km': value['historyMaxDistanceKm'],
        'distance_tolerance_km': value['distanceToleranceKm'],
        'history_login_count': value['historyLoginCount'],
        'check_impossible_travel': value['checkImpossibleTravel'],
        'impossible_tolerance_km': value['impossibleToleranceKm'],
    };
}

