/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2026.5.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 type { ClientTypeEnum } from "./ClientTypeEnum";
import { ClientTypeEnumFromJSON, ClientTypeEnumToJSON } from "./ClientTypeEnum";
import type { IssuerModeEnum } from "./IssuerModeEnum";
import { IssuerModeEnumFromJSON, IssuerModeEnumToJSON } from "./IssuerModeEnum";
import type { OAuth2ProviderLogoutMethodEnum } from "./OAuth2ProviderLogoutMethodEnum";
import {
    OAuth2ProviderLogoutMethodEnumFromJSON,
    OAuth2ProviderLogoutMethodEnumToJSON,
} from "./OAuth2ProviderLogoutMethodEnum";
import type { RedirectURI } from "./RedirectURI";
import { RedirectURIFromJSON, RedirectURIToJSON } from "./RedirectURI";
import type { SubModeEnum } from "./SubModeEnum";
import { SubModeEnumFromJSON, SubModeEnumToJSON } from "./SubModeEnum";

/**
 * OAuth2Provider Serializer
 * @export
 * @interface OAuth2Provider
 */
export interface OAuth2Provider {
    /**
     *
     * @type {number}
     * @memberof OAuth2Provider
     */
    readonly pk: number;
    /**
     *
     * @type {string}
     * @memberof OAuth2Provider
     */
    name: string;
    /**
     * Flow used for authentication when the associated application is accessed by an un-authenticated user.
     * @type {string}
     * @memberof OAuth2Provider
     */
    authenticationFlow?: string | null;
    /**
     * Flow used when authorizing this provider.
     * @type {string}
     * @memberof OAuth2Provider
     */
    authorizationFlow: string;
    /**
     * Flow used ending the session from a provider.
     * @type {string}
     * @memberof OAuth2Provider
     */
    invalidationFlow: string;
    /**
     *
     * @type {Array<string>}
     * @memberof OAuth2Provider
     */
    propertyMappings?: Array<string>;
    /**
     * Get object component so that we know how to edit the object
     * @type {string}
     * @memberof OAuth2Provider
     */
    readonly component: string;
    /**
     * Internal application name, used in URLs.
     * @type {string}
     * @memberof OAuth2Provider
     */
    readonly assignedApplicationSlug: string | null;
    /**
     * Application's display Name.
     * @type {string}
     * @memberof OAuth2Provider
     */
    readonly assignedApplicationName: string | null;
    /**
     * Internal application name, used in URLs.
     * @type {string}
     * @memberof OAuth2Provider
     */
    readonly assignedBackchannelApplicationSlug: string | null;
    /**
     * Application's display Name.
     * @type {string}
     * @memberof OAuth2Provider
     */
    readonly assignedBackchannelApplicationName: string | null;
    /**
     * Return object's verbose_name
     * @type {string}
     * @memberof OAuth2Provider
     */
    readonly verboseName: string;
    /**
     * Return object's plural verbose_name
     * @type {string}
     * @memberof OAuth2Provider
     */
    readonly verboseNamePlural: string;
    /**
     * Return internal model name
     * @type {string}
     * @memberof OAuth2Provider
     */
    readonly metaModelName: string;
    /**
     * Confidential clients are capable of maintaining the confidentiality of their credentials. Public clients are incapable
     * @type {ClientTypeEnum}
     * @memberof OAuth2Provider
     */
    clientType?: ClientTypeEnum;
    /**
     *
     * @type {string}
     * @memberof OAuth2Provider
     */
    clientId?: string;
    /**
     *
     * @type {string}
     * @memberof OAuth2Provider
     */
    clientSecret?: string;
    /**
     * Access codes not valid on or after current time + this value (Format: hours=1;minutes=2;seconds=3).
     * @type {string}
     * @memberof OAuth2Provider
     */
    accessCodeValidity?: string;
    /**
     * Tokens not valid on or after current time + this value (Format: hours=1;minutes=2;seconds=3).
     * @type {string}
     * @memberof OAuth2Provider
     */
    accessTokenValidity?: string;
    /**
     * Tokens not valid on or after current time + this value (Format: hours=1;minutes=2;seconds=3).
     * @type {string}
     * @memberof OAuth2Provider
     */
    refreshTokenValidity?: string;
    /**
     * When refreshing a token, if the refresh token is valid for less than this duration, it will be renewed. When set to seconds=0, token will always be renewed. (Format: hours=1;minutes=2;seconds=3).
     * @type {string}
     * @memberof OAuth2Provider
     */
    refreshTokenThreshold?: string;
    /**
     * Include User claims from scopes in the id_token, for applications that don't access the userinfo endpoint.
     * @type {boolean}
     * @memberof OAuth2Provider
     */
    includeClaimsInIdToken?: boolean;
    /**
     * Key used to sign the tokens.
     * @type {string}
     * @memberof OAuth2Provider
     */
    signingKey?: string | null;
    /**
     * Key used to encrypt the tokens. When set, tokens will be encrypted and returned as JWEs.
     * @type {string}
     * @memberof OAuth2Provider
     */
    encryptionKey?: string | null;
    /**
     *
     * @type {Array<RedirectURI>}
     * @memberof OAuth2Provider
     */
    redirectUris: Array<RedirectURI>;
    /**
     *
     * @type {string}
     * @memberof OAuth2Provider
     */
    logoutUri?: string;
    /**
     * Backchannel logs out with server to server calls. Frontchannel uses iframes in your browser
     * @type {OAuth2ProviderLogoutMethodEnum}
     * @memberof OAuth2Provider
     */
    logoutMethod?: OAuth2ProviderLogoutMethodEnum;
    /**
     * Configure what data should be used as unique User Identifier. For most cases, the default should be fine.
     * @type {SubModeEnum}
     * @memberof OAuth2Provider
     */
    subMode?: SubModeEnum;
    /**
     * Configure how the issuer field of the ID Token should be filled.
     * @type {IssuerModeEnum}
     * @memberof OAuth2Provider
     */
    issuerMode?: IssuerModeEnum;
    /**
     *
     * @type {Array<string>}
     * @memberof OAuth2Provider
     */
    jwtFederationSources?: Array<string>;
    /**
     *
     * @type {Array<number>}
     * @memberof OAuth2Provider
     */
    jwtFederationProviders?: Array<number>;
}

/**
 * Check if a given object implements the OAuth2Provider interface.
 */
export function instanceOfOAuth2Provider(value: object): value is OAuth2Provider {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("authorizationFlow" in value) || value["authorizationFlow"] === undefined) return false;
    if (!("invalidationFlow" in value) || value["invalidationFlow"] === undefined) return false;
    if (!("component" in value) || value["component"] === undefined) return false;
    if (!("assignedApplicationSlug" in value) || value["assignedApplicationSlug"] === undefined)
        return false;
    if (!("assignedApplicationName" in value) || value["assignedApplicationName"] === undefined)
        return false;
    if (
        !("assignedBackchannelApplicationSlug" in value) ||
        value["assignedBackchannelApplicationSlug"] === undefined
    )
        return false;
    if (
        !("assignedBackchannelApplicationName" in value) ||
        value["assignedBackchannelApplicationName"] === undefined
    )
        return false;
    if (!("verboseName" in value) || value["verboseName"] === undefined) return false;
    if (!("verboseNamePlural" in value) || value["verboseNamePlural"] === undefined) return false;
    if (!("metaModelName" in value) || value["metaModelName"] === undefined) return false;
    if (!("redirectUris" in value) || value["redirectUris"] === undefined) return false;
    return true;
}

export function OAuth2ProviderFromJSON(json: any): OAuth2Provider {
    return OAuth2ProviderFromJSONTyped(json, false);
}

export function OAuth2ProviderFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): OAuth2Provider {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        name: json["name"],
        authenticationFlow:
            json["authentication_flow"] == null ? undefined : json["authentication_flow"],
        authorizationFlow: json["authorization_flow"],
        invalidationFlow: json["invalidation_flow"],
        propertyMappings: json["property_mappings"] == null ? undefined : json["property_mappings"],
        component: json["component"],
        assignedApplicationSlug: json["assigned_application_slug"],
        assignedApplicationName: json["assigned_application_name"],
        assignedBackchannelApplicationSlug: json["assigned_backchannel_application_slug"],
        assignedBackchannelApplicationName: json["assigned_backchannel_application_name"],
        verboseName: json["verbose_name"],
        verboseNamePlural: json["verbose_name_plural"],
        metaModelName: json["meta_model_name"],
        clientType:
            json["client_type"] == null ? undefined : ClientTypeEnumFromJSON(json["client_type"]),
        clientId: json["client_id"] == null ? undefined : json["client_id"],
        clientSecret: json["client_secret"] == null ? undefined : json["client_secret"],
        accessCodeValidity:
            json["access_code_validity"] == null ? undefined : json["access_code_validity"],
        accessTokenValidity:
            json["access_token_validity"] == null ? undefined : json["access_token_validity"],
        refreshTokenValidity:
            json["refresh_token_validity"] == null ? undefined : json["refresh_token_validity"],
        refreshTokenThreshold:
            json["refresh_token_threshold"] == null ? undefined : json["refresh_token_threshold"],
        includeClaimsInIdToken:
            json["include_claims_in_id_token"] == null
                ? undefined
                : json["include_claims_in_id_token"],
        signingKey: json["signing_key"] == null ? undefined : json["signing_key"],
        encryptionKey: json["encryption_key"] == null ? undefined : json["encryption_key"],
        redirectUris: (json["redirect_uris"] as Array<any>).map(RedirectURIFromJSON),
        logoutUri: json["logout_uri"] == null ? undefined : json["logout_uri"],
        logoutMethod:
            json["logout_method"] == null
                ? undefined
                : OAuth2ProviderLogoutMethodEnumFromJSON(json["logout_method"]),
        subMode: json["sub_mode"] == null ? undefined : SubModeEnumFromJSON(json["sub_mode"]),
        issuerMode:
            json["issuer_mode"] == null ? undefined : IssuerModeEnumFromJSON(json["issuer_mode"]),
        jwtFederationSources:
            json["jwt_federation_sources"] == null ? undefined : json["jwt_federation_sources"],
        jwtFederationProviders:
            json["jwt_federation_providers"] == null ? undefined : json["jwt_federation_providers"],
    };
}

export function OAuth2ProviderToJSON(json: any): OAuth2Provider {
    return OAuth2ProviderToJSONTyped(json, false);
}

export function OAuth2ProviderToJSONTyped(
    value?: Omit<
        OAuth2Provider,
        | "pk"
        | "component"
        | "assigned_application_slug"
        | "assigned_application_name"
        | "assigned_backchannel_application_slug"
        | "assigned_backchannel_application_name"
        | "verbose_name"
        | "verbose_name_plural"
        | "meta_model_name"
    > | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
        authentication_flow: value["authenticationFlow"],
        authorization_flow: value["authorizationFlow"],
        invalidation_flow: value["invalidationFlow"],
        property_mappings: value["propertyMappings"],
        client_type: ClientTypeEnumToJSON(value["clientType"]),
        client_id: value["clientId"],
        client_secret: value["clientSecret"],
        access_code_validity: value["accessCodeValidity"],
        access_token_validity: value["accessTokenValidity"],
        refresh_token_validity: value["refreshTokenValidity"],
        refresh_token_threshold: value["refreshTokenThreshold"],
        include_claims_in_id_token: value["includeClaimsInIdToken"],
        signing_key: value["signingKey"],
        encryption_key: value["encryptionKey"],
        redirect_uris: (value["redirectUris"] as Array<any>).map(RedirectURIToJSON),
        logout_uri: value["logoutUri"],
        logout_method: OAuth2ProviderLogoutMethodEnumToJSON(value["logoutMethod"]),
        sub_mode: SubModeEnumToJSON(value["subMode"]),
        issuer_mode: IssuerModeEnumToJSON(value["issuerMode"]),
        jwt_federation_sources: value["jwtFederationSources"],
        jwt_federation_providers: value["jwtFederationProviders"],
    };
}
