/* 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 { AuthorizationCodeAuthMethodEnum } from "./AuthorizationCodeAuthMethodEnum";
import {
    AuthorizationCodeAuthMethodEnumFromJSON,
    AuthorizationCodeAuthMethodEnumToJSON,
} from "./AuthorizationCodeAuthMethodEnum";
import type { GroupMatchingModeEnum } from "./GroupMatchingModeEnum";
import {
    GroupMatchingModeEnumFromJSON,
    GroupMatchingModeEnumToJSON,
} from "./GroupMatchingModeEnum";
import type { PKCEMethodEnum } from "./PKCEMethodEnum";
import { PKCEMethodEnumFromJSON, PKCEMethodEnumToJSON } from "./PKCEMethodEnum";
import type { PolicyEngineMode } from "./PolicyEngineMode";
import { PolicyEngineModeFromJSON, PolicyEngineModeToJSON } from "./PolicyEngineMode";
import type { ProviderTypeEnum } from "./ProviderTypeEnum";
import { ProviderTypeEnumFromJSON, ProviderTypeEnumToJSON } from "./ProviderTypeEnum";
import type { SourceType } from "./SourceType";
import { SourceTypeFromJSON } from "./SourceType";
import type { ThemedUrls } from "./ThemedUrls";
import { ThemedUrlsFromJSON } from "./ThemedUrls";
import type { UserMatchingModeEnum } from "./UserMatchingModeEnum";
import { UserMatchingModeEnumFromJSON, UserMatchingModeEnumToJSON } from "./UserMatchingModeEnum";

/**
 * OAuth Source Serializer
 * @export
 * @interface OAuthSource
 */
export interface OAuthSource {
    /**
     *
     * @type {string}
     * @memberof OAuthSource
     */
    readonly pk: string;
    /**
     * Source's display Name.
     * @type {string}
     * @memberof OAuthSource
     */
    name: string;
    /**
     * Internal source name, used in URLs.
     * @type {string}
     * @memberof OAuthSource
     */
    slug: string;
    /**
     *
     * @type {boolean}
     * @memberof OAuthSource
     */
    enabled?: boolean;
    /**
     * When enabled, this source will be displayed as a prominent button on the login page, instead of a small icon.
     * @type {boolean}
     * @memberof OAuthSource
     */
    promoted?: boolean;
    /**
     * Flow to use when authenticating existing users.
     * @type {string}
     * @memberof OAuthSource
     */
    authenticationFlow?: string | null;
    /**
     * Flow to use when enrolling new users.
     * @type {string}
     * @memberof OAuthSource
     */
    enrollmentFlow?: string | null;
    /**
     *
     * @type {Array<string>}
     * @memberof OAuthSource
     */
    userPropertyMappings?: Array<string>;
    /**
     *
     * @type {Array<string>}
     * @memberof OAuthSource
     */
    groupPropertyMappings?: Array<string>;
    /**
     * Get object component so that we know how to edit the object
     * @type {string}
     * @memberof OAuthSource
     */
    readonly component: string;
    /**
     * Return object's verbose_name
     * @type {string}
     * @memberof OAuthSource
     */
    readonly verboseName: string;
    /**
     * Return object's plural verbose_name
     * @type {string}
     * @memberof OAuthSource
     */
    readonly verboseNamePlural: string;
    /**
     * Return internal model name
     * @type {string}
     * @memberof OAuthSource
     */
    readonly metaModelName: string;
    /**
     *
     * @type {PolicyEngineMode}
     * @memberof OAuthSource
     */
    policyEngineMode?: PolicyEngineMode;
    /**
     * How the source determines if an existing user should be authenticated or a new user enrolled.
     * @type {UserMatchingModeEnum}
     * @memberof OAuthSource
     */
    userMatchingMode?: UserMatchingModeEnum;
    /**
     * Objects that are managed by authentik. These objects are created and updated automatically. This flag only indicates that an object can be overwritten by migrations. You can still modify the objects via the API, but expect changes to be overwritten in a later update.
     * @type {string}
     * @memberof OAuthSource
     */
    readonly managed: string | null;
    /**
     *
     * @type {string}
     * @memberof OAuthSource
     */
    userPathTemplate?: string;
    /**
     *
     * @type {string}
     * @memberof OAuthSource
     */
    icon?: string;
    /**
     *
     * @type {string}
     * @memberof OAuthSource
     */
    readonly iconUrl: string | null;
    /**
     *
     * @type {ThemedUrls}
     * @memberof OAuthSource
     */
    readonly iconThemedUrls: ThemedUrls | null;
    /**
     * How the source determines if an existing group should be used or a new group created.
     * @type {GroupMatchingModeEnum}
     * @memberof OAuthSource
     */
    groupMatchingMode?: GroupMatchingModeEnum;
    /**
     *
     * @type {ProviderTypeEnum}
     * @memberof OAuthSource
     */
    providerType: ProviderTypeEnum;
    /**
     * URL used to request the initial token. This URL is only required for OAuth 1.
     * @type {string}
     * @memberof OAuthSource
     */
    requestTokenUrl?: string | null;
    /**
     * URL the user is redirect to to conest the flow.
     * @type {string}
     * @memberof OAuthSource
     */
    authorizationUrl?: string | null;
    /**
     * URL used by authentik to retrieve tokens.
     * @type {string}
     * @memberof OAuthSource
     */
    accessTokenUrl?: string | null;
    /**
     * URL used by authentik to get user information.
     * @type {string}
     * @memberof OAuthSource
     */
    profileUrl?: string | null;
    /**
     *
     * @type {PKCEMethodEnum}
     * @memberof OAuthSource
     */
    pkce?: PKCEMethodEnum;
    /**
     *
     * @type {string}
     * @memberof OAuthSource
     */
    consumerKey: string;
    /**
     * Get OAuth Callback URL
     * @type {string}
     * @memberof OAuthSource
     */
    readonly callbackUrl: string;
    /**
     *
     * @type {string}
     * @memberof OAuthSource
     */
    additionalScopes?: string;
    /**
     *
     * @type {SourceType}
     * @memberof OAuthSource
     */
    readonly type: SourceType;
    /**
     *
     * @type {string}
     * @memberof OAuthSource
     */
    oidcWellKnownUrl?: string;
    /**
     *
     * @type {string}
     * @memberof OAuthSource
     */
    oidcJwksUrl?: string;
    /**
     *
     * @type {{ [key: string]: any; }}
     * @memberof OAuthSource
     */
    oidcJwks?: { [key: string]: any };
    /**
     * How to perform authentication during an authorization_code token request flow
     * @type {AuthorizationCodeAuthMethodEnum}
     * @memberof OAuthSource
     */
    authorizationCodeAuthMethod?: AuthorizationCodeAuthMethodEnum;
}

/**
 * Check if a given object implements the OAuthSource interface.
 */
export function instanceOfOAuthSource(value: object): value is OAuthSource {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("slug" in value) || value["slug"] === undefined) return false;
    if (!("component" in value) || value["component"] === 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 (!("managed" in value) || value["managed"] === undefined) return false;
    if (!("iconUrl" in value) || value["iconUrl"] === undefined) return false;
    if (!("iconThemedUrls" in value) || value["iconThemedUrls"] === undefined) return false;
    if (!("providerType" in value) || value["providerType"] === undefined) return false;
    if (!("consumerKey" in value) || value["consumerKey"] === undefined) return false;
    if (!("callbackUrl" in value) || value["callbackUrl"] === undefined) return false;
    if (!("type" in value) || value["type"] === undefined) return false;
    return true;
}

export function OAuthSourceFromJSON(json: any): OAuthSource {
    return OAuthSourceFromJSONTyped(json, false);
}

export function OAuthSourceFromJSONTyped(json: any, ignoreDiscriminator: boolean): OAuthSource {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        name: json["name"],
        slug: json["slug"],
        enabled: json["enabled"] == null ? undefined : json["enabled"],
        promoted: json["promoted"] == null ? undefined : json["promoted"],
        authenticationFlow:
            json["authentication_flow"] == null ? undefined : json["authentication_flow"],
        enrollmentFlow: json["enrollment_flow"] == null ? undefined : json["enrollment_flow"],
        userPropertyMappings:
            json["user_property_mappings"] == null ? undefined : json["user_property_mappings"],
        groupPropertyMappings:
            json["group_property_mappings"] == null ? undefined : json["group_property_mappings"],
        component: json["component"],
        verboseName: json["verbose_name"],
        verboseNamePlural: json["verbose_name_plural"],
        metaModelName: json["meta_model_name"],
        policyEngineMode:
            json["policy_engine_mode"] == null
                ? undefined
                : PolicyEngineModeFromJSON(json["policy_engine_mode"]),
        userMatchingMode:
            json["user_matching_mode"] == null
                ? undefined
                : UserMatchingModeEnumFromJSON(json["user_matching_mode"]),
        managed: json["managed"],
        userPathTemplate:
            json["user_path_template"] == null ? undefined : json["user_path_template"],
        icon: json["icon"] == null ? undefined : json["icon"],
        iconUrl: json["icon_url"],
        iconThemedUrls: ThemedUrlsFromJSON(json["icon_themed_urls"]),
        groupMatchingMode:
            json["group_matching_mode"] == null
                ? undefined
                : GroupMatchingModeEnumFromJSON(json["group_matching_mode"]),
        providerType: ProviderTypeEnumFromJSON(json["provider_type"]),
        requestTokenUrl: json["request_token_url"] == null ? undefined : json["request_token_url"],
        authorizationUrl: json["authorization_url"] == null ? undefined : json["authorization_url"],
        accessTokenUrl: json["access_token_url"] == null ? undefined : json["access_token_url"],
        profileUrl: json["profile_url"] == null ? undefined : json["profile_url"],
        pkce: json["pkce"] == null ? undefined : PKCEMethodEnumFromJSON(json["pkce"]),
        consumerKey: json["consumer_key"],
        callbackUrl: json["callback_url"],
        additionalScopes: json["additional_scopes"] == null ? undefined : json["additional_scopes"],
        type: SourceTypeFromJSON(json["type"]),
        oidcWellKnownUrl:
            json["oidc_well_known_url"] == null ? undefined : json["oidc_well_known_url"],
        oidcJwksUrl: json["oidc_jwks_url"] == null ? undefined : json["oidc_jwks_url"],
        oidcJwks: json["oidc_jwks"] == null ? undefined : json["oidc_jwks"],
        authorizationCodeAuthMethod:
            json["authorization_code_auth_method"] == null
                ? undefined
                : AuthorizationCodeAuthMethodEnumFromJSON(json["authorization_code_auth_method"]),
    };
}

export function OAuthSourceToJSON(json: any): OAuthSource {
    return OAuthSourceToJSONTyped(json, false);
}

export function OAuthSourceToJSONTyped(
    value?: Omit<
        OAuthSource,
        | "pk"
        | "component"
        | "verbose_name"
        | "verbose_name_plural"
        | "meta_model_name"
        | "managed"
        | "icon_url"
        | "icon_themed_urls"
        | "callback_url"
        | "type"
    > | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
        slug: value["slug"],
        enabled: value["enabled"],
        promoted: value["promoted"],
        authentication_flow: value["authenticationFlow"],
        enrollment_flow: value["enrollmentFlow"],
        user_property_mappings: value["userPropertyMappings"],
        group_property_mappings: value["groupPropertyMappings"],
        policy_engine_mode: PolicyEngineModeToJSON(value["policyEngineMode"]),
        user_matching_mode: UserMatchingModeEnumToJSON(value["userMatchingMode"]),
        user_path_template: value["userPathTemplate"],
        icon: value["icon"],
        group_matching_mode: GroupMatchingModeEnumToJSON(value["groupMatchingMode"]),
        provider_type: ProviderTypeEnumToJSON(value["providerType"]),
        request_token_url: value["requestTokenUrl"],
        authorization_url: value["authorizationUrl"],
        access_token_url: value["accessTokenUrl"],
        profile_url: value["profileUrl"],
        pkce: PKCEMethodEnumToJSON(value["pkce"]),
        consumer_key: value["consumerKey"],
        additional_scopes: value["additionalScopes"],
        oidc_well_known_url: value["oidcWellKnownUrl"],
        oidc_jwks_url: value["oidcJwksUrl"],
        oidc_jwks: value["oidcJwks"],
        authorization_code_auth_method: AuthorizationCodeAuthMethodEnumToJSON(
            value["authorizationCodeAuthMethod"],
        ),
    };
}
