// AUTO-GENERATED — do not edit by hand
// Upstream: https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/Currents/Currents.node.ts
// To implement: copy to ../impl/currents.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 CurrentsNode;

static META: NodeMetadata = NodeMetadata {
    name: "currents",
    display_name: "Currents",
    version: &[1],
    group: &["transform"],
    description: "Interact with the Currents API for test orchestration and analytics",
    inputs: 1,
    outputs: 1,
    properties: &[
    PropertyDef { name: "resource", display_name: "Resource", kind: PropertyKind::Options, required: false, default: Some("run") }
],
    credentials: &[
    CredentialRef { name: "currentsApi", required: true }
],
};

#[async_trait]
impl Node for CurrentsNode {
    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: "https://api.currents.dev/v1",
            credential: Some("currentsApi"),
            auth_headers: &[("Authorization", "Bearer {{apiKey}}")],
            auth_query: &[],
            dispatch_param: "operation",
            operations: &[
                crate::engine::routing::OperationDescriptor {
                    value: "create", method: "POST", url_template: "/actions",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "delete", method: "DELETE", url_template: "/actions/{{$parameter[",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "disable", method: "PUT", url_template: "/actions/{{$parameter[",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "enable", method: "PUT", url_template: "/actions/{{$parameter[",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "get", method: "GET", url_template: "/actions/{{$parameter[",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "getAll", method: "GET", url_template: "/actions",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "update", method: "PUT", url_template: "/actions/{{$parameter[",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "getInsights", method: "GET", url_template: "/projects/{{$parameter[",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "cancel", method: "PUT", url_template: "/runs/{{$parameter[",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "cancelGithub", method: "PUT", url_template: "/runs/cancel-ci/github",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "find", method: "GET", url_template: "/runs/find",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "reset", method: "PUT", url_template: "/runs/{{$parameter[",
                    body_template: "", query: &[],
                },
                crate::engine::routing::OperationDescriptor {
                    value: "generate", method: "POST", url_template: "/signature/test",
                    body_template: "", query: &[],
                }
            ],
            sends: &[
                crate::engine::routing::SendDescriptor {
                    param_name: "authors", send_type: "query", dest_key: "authors",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "branches", send_type: "query", dest_key: "branches",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "groups", send_type: "query", dest_key: "groups",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "tags", send_type: "query", dest_key: "tags",
                    operations: &[], resources: &[],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "actionId", send_type: "query", dest_key: "projectId",
                    operations: &["getAll"], resources: &["action"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "search", send_type: "query", dest_key: "search",
                    operations: &["getAll"], resources: &["action"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "Expired", send_type: "query", dest_key: "status",
                    operations: &["getAll"], resources: &["action"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "name", send_type: "body", dest_key: "name",
                    operations: &["create"], resources: &["action"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "Tag", send_type: "body", dest_key: "action",
                    operations: &["create"], resources: &["action"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "actionTags", send_type: "body", dest_key: "action",
                    operations: &["create"], resources: &["action"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "matcherValue", send_type: "body", dest_key: "matcher",
                    operations: &["create"], resources: &["action"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "description", send_type: "body", dest_key: "description",
                    operations: &["create"], resources: &["action"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "expiresAfter", send_type: "body", dest_key: "expiresAfter",
                    operations: &["create"], resources: &["action"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "dateStart", send_type: "query", dest_key: "date_start",
                    operations: &["getAll"], resources: &["testResult"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "dateEnd", send_type: "query", dest_key: "date_end",
                    operations: &["getAll"], resources: &["testResult"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "limit", send_type: "query", dest_key: "limit",
                    operations: &["getAll"], resources: &["testResult"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "Skipped", send_type: "query", dest_key: "status",
                    operations: &["getAll"], resources: &["testResult"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "startingAfter", send_type: "query", dest_key: "starting_after",
                    operations: &["getAll"], resources: &["testResult"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "endingBefore", send_type: "query", dest_key: "ending_before",
                    operations: &["getAll"], resources: &["testResult"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "resolution", send_type: "query", dest_key: "resolution",
                    operations: &["getInsights"], resources: &["project"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "machineIds", send_type: "body", dest_key: "machineId",
                    operations: &["reset"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "isBatchedOr8n", send_type: "body", dest_key: "isBatchedOr8n",
                    operations: &["reset"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "githubRunId", send_type: "body", dest_key: "githubRunId",
                    operations: &["cancelGithub"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "githubRunAttempt", send_type: "body", dest_key: "githubRunAttempt",
                    operations: &["cancelGithub"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "projectId", send_type: "body", dest_key: "projectId",
                    operations: &["cancelGithub"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "ciBuildId", send_type: "body", dest_key: "ciBuildId",
                    operations: &["cancelGithub"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "ciBuildId", send_type: "query", dest_key: "projectId",
                    operations: &["find", "getAll"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "branch", send_type: "query", dest_key: "branch",
                    operations: &["find"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "Timeout", send_type: "query", dest_key: "completion_state",
                    operations: &["getAll"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "Running", send_type: "query", dest_key: "status",
                    operations: &["getAll"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "OR", send_type: "query", dest_key: "tag_operator",
                    operations: &["getAll"], resources: &["run"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "specNameFilter", send_type: "query", dest_key: "specNameFilter",
                    operations: &["getAll"], resources: &["specFile"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "includeFailedInDuration", send_type: "query", dest_key: "includeFailedInDuration",
                    operations: &["getAll"], resources: &["specFile"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "order", send_type: "query", dest_key: "order",
                    operations: &["getAll"], resources: &["specFile"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "Descending", send_type: "query", dest_key: "dir",
                    operations: &["getAll"], resources: &["specFile"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "page", send_type: "query", dest_key: "page",
                    operations: &["getAll"], resources: &["specFile"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "minExecutions", send_type: "query", dest_key: "min_executions",
                    operations: &["getAll"], resources: &["test"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "spec", send_type: "query", dest_key: "spec",
                    operations: &["getAll"], resources: &["test"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "title", send_type: "query", dest_key: "title",
                    operations: &["getAll"], resources: &["test"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "Title", send_type: "query", dest_key: "order",
                    operations: &["getAll"], resources: &["test"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "metric_settings", send_type: "query", dest_key: "metric_settings",
                    operations: &["getAll"], resources: &["test"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "Generate", send_type: "body", dest_key: "projectId",
                    operations: &["generate"], resources: &["signature"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "specFilePath", send_type: "body", dest_key: "specFilePath",
                    operations: &["generate"], resources: &["signature"],
                },
                crate::engine::routing::SendDescriptor {
                    param_name: "testTitle", send_type: "body", dest_key: "testTitle",
                    operations: &["generate"], resources: &["signature"],
                }
            ],
        };
    crate::engine::routing::execute_routing(&ROUTING, _ctx).await
    }
}

inventory::submit! { NodeFactory::new("currents", || Arc::new(CurrentsNode)) }
