// AUTO-GENERATED — do not edit by hand
// Upstream: https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/Okta/Okta.node.ts
// To implement: copy to ../impl/okta.rs, fill in execute(), add to ../impl/mod.rs
// r8r: rust port of n8n.io
// License: Unlicense

use async_trait::async_trait;
use crate::core::error::NodeError;
use crate::core::types::*;
use crate::engine::{ExecuteCtx, Node, NodeFactory};
use std::sync::Arc;

pub struct OktaNode;

static META: NodeMetadata = NodeMetadata {
    name: "okta",
    display_name: "Okta",
    version: &[1],
    group: &["transform"],
    description: "Use the Okta API",
    inputs: 1,
    outputs: 1,
    properties: &[
    PropertyDef { name: "resource", display_name: "Resource", kind: PropertyKind::Options, required: false, default: Some("user") }
],
    credentials: &[
    CredentialRef { name: "oktaApi", required: true }
],
};

#[async_trait]
impl Node for OktaNode {
    fn metadata(&self) -> &'static NodeMetadata { &META }

    async fn execute(&self, _ctx: &mut ExecuteCtx<'_>) -> Result<NodeOutput, NodeError> {
    static ROUTING: crate::engine::routing::RoutingDescriptor =
        crate::engine::routing::RoutingDescriptor {
            base_url: "={{$credentials.url.replace(new RegExp(",
            credential: Some("oktaApi"),
            auth_headers: &[("Authorization", "SSWS {{accessToken}}")],
            auth_query: &[],
            dispatch_param: "operation",
            operations: &[
                crate::engine::routing::OperationDescriptor {
                    value: "delete", method: "DELETE", url_template: "{{",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "get", method: "GET", url_template: "{{",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "update", method: "POST", url_template: "{{",
                    body_template: "", query: &[],
                }
            ],
            sends: &[
                crate::engine::routing::SendDescriptor {
                    param_name: "firstName", send_type: "body", dest_key: "profile.firstName",
                    operations: &[], resources: &["user"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "lastName", send_type: "body", dest_key: "profile.lastName",
                    operations: &[], resources: &["user"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "login", send_type: "body", dest_key: "profile.login",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "email", send_type: "body", dest_key: "profile.email",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "city", send_type: "body", dest_key: "profile.city",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "costCenter", send_type: "body", dest_key: "profile.costCenter",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "countryCode", send_type: "body", dest_key: "profile.countryCode",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "department", send_type: "body", dest_key: "profile.department",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "displayName", send_type: "body", dest_key: "profile.displayName",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "division", send_type: "body", dest_key: "profile.division",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "employeeNumber", send_type: "body", dest_key: "profile.employeeNumber",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "honorificPrefix", send_type: "body", dest_key: "profile.honorificPrefix",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "honorificSuffix", send_type: "body", dest_key: "profile.honorificSuffix",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "locale", send_type: "body", dest_key: "profile.locale",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "manager", send_type: "body", dest_key: "profile.manager",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "managerId", send_type: "body", dest_key: "profile.managerId",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "middleName", send_type: "body", dest_key: "profile.middleName",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "mobilePhone", send_type: "body", dest_key: "profile.mobilePhone",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "nickName", send_type: "body", dest_key: "profile.nickName",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "password", send_type: "body", dest_key: "credentials.password.value",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "organization", send_type: "body", dest_key: "profile.organization",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "postalAddress", send_type: "body", dest_key: "profile.postalAddress",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "preferredLanguage", send_type: "body", dest_key: "profile.preferredLanguage",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "primaryPhone", send_type: "body", dest_key: "profile.primaryPhone",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "profileUrl", send_type: "body", dest_key: "profile.profileUrl",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "recoveryQuestionAnswer", send_type: "body", dest_key: "credentials.recovery_question.answer",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "recoveryQuestionQuestion", send_type: "body", dest_key: "credentials.recovery_question.question",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "secondEmail", send_type: "body", dest_key: "profile.secondEmail",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "state", send_type: "body", dest_key: "profile.state",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "streetAddress", send_type: "body", dest_key: "profile.streetAddress",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "timezone", send_type: "body", dest_key: "profile.timezone",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "title", send_type: "body", dest_key: "profile.title",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "userType", send_type: "body", dest_key: "profile.userType",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "zipCode", send_type: "body", dest_key: "profile.zipCode",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "limit", send_type: "query", dest_key: "limit",
                    operations: &["getAll"], resources: &["user"],
                }
            ],
        };
    crate::engine::routing::execute_routing(&ROUTING, _ctx).await
    }
}

inventory::submit! { NodeFactory::new("okta", || Arc::new(OktaNode)) }
