Skip to main content

ironflow_ops_gitlab/
lib.rs

1//! GitLab integration for Ironflow workflows.
2//!
3//! This crate provides a thin integration layer between the
4//! [`gitlab`](https://crates.io/crates/gitlab) crate and Ironflow's workflow
5//! engine. It re-exports the full `gitlab` API so that workflow handlers get
6//! typed, builder-based access to every GitLab endpoint without managing
7//! authentication or HTTP clients manually.
8//!
9//! # Quick start
10//!
11//! ```no_run
12//! use ironflow_ops_gitlab::GitLab;
13//! use ironflow_core::operation::{OperationContext, NoopSecretResolver};
14//! use std::sync::Arc;
15//!
16//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
17//! let ctx = OperationContext::new(Arc::new(NoopSecretResolver));
18//! let gitlab = GitLab::from_context(&ctx).await?;
19//! # Ok(())
20//! # }
21//! ```
22//!
23//! # Typed queries
24//!
25//! Use the re-exported [`gitlab::api`] builders and [`gitlab::api::AsyncQuery`] to call any
26//! endpoint with a typed response:
27//!
28//! ```no_run
29//! use ironflow_ops_gitlab::GitLab;
30//! use gitlab::api::{projects, AsyncQuery};
31//! use ironflow_core::operation::{OperationContext, NoopSecretResolver};
32//! use std::sync::Arc;
33//!
34//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
35//! let ctx = OperationContext::new(Arc::new(NoopSecretResolver));
36//! let gitlab = GitLab::from_context(&ctx).await?;
37//!
38//! let endpoint = projects::Project::builder().project(42).build()?;
39//! let project: serde_json::Value = endpoint.query_async(gitlab.client()).await?;
40//! # Ok(())
41//! # }
42//! ```
43//!
44//! # Tracked operations
45//!
46//! Wrap any endpoint in [`GitLabOp`] to execute it as a tracked workflow step
47//! via `WorkflowContext::operation()`:
48//!
49//! ```no_run
50//! use ironflow_ops_gitlab::GitLab;
51//! use gitlab::api::projects;
52//! use ironflow_core::operation::{OperationContext, NoopSecretResolver};
53//! use std::sync::Arc;
54//!
55//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
56//! let ctx = OperationContext::new(Arc::new(NoopSecretResolver));
57//! let gitlab = GitLab::from_context(&ctx).await?;
58//!
59//! let endpoint = projects::Project::builder().project(42).build()?;
60//! let op = gitlab.op(endpoint);
61//! // op implements Operation -- pass it to ctx.operation("get-project", &op)
62//! # Ok(())
63//! # }
64//! ```
65//!
66//! # Missing endpoints
67//!
68//! Some GitLab REST routes are not implemented by the `gitlab` crate. This crate fills
69//! those gaps under [`endpoints`], wired the same way as any other endpoint:
70//!
71//! ```no_run
72//! use ironflow_ops_gitlab::GitLab;
73//! use ironflow_ops_gitlab::endpoints::merge_requests::CreateMergeRequestDiscussionNote;
74//! use gitlab::api::common::NameOrId;
75//! use ironflow_core::operation::{OperationContext, NoopSecretResolver};
76//! use std::sync::Arc;
77//!
78//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
79//! let ctx = OperationContext::new(Arc::new(NoopSecretResolver));
80//! let gitlab = GitLab::from_context(&ctx).await?;
81//!
82//! let endpoint = CreateMergeRequestDiscussionNote {
83//!     project: NameOrId::from(42),
84//!     merge_request: 7,
85//!     discussion_id: "abcd1234".to_string(),
86//!     body: "Looks good, thanks!".to_string(),
87//! };
88//! let op = gitlab.op(endpoint);
89//! # Ok(())
90//! # }
91//! ```
92//!
93//! # Paginated operations
94//!
95//! Use [`GitLab::paged_op`] to drive a pageable "list ..." endpoint across every page and
96//! get back a single JSON array concatenating every page's results:
97//!
98//! ```no_run
99//! use ironflow_ops_gitlab::GitLab;
100//! use gitlab::api::projects::merge_requests::MergeRequests;
101//! use gitlab::api::Pagination;
102//! use ironflow_core::operation::{OperationContext, NoopSecretResolver};
103//! use std::sync::Arc;
104//!
105//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
106//! let ctx = OperationContext::new(Arc::new(NoopSecretResolver));
107//! let gitlab = GitLab::from_context(&ctx).await?;
108//!
109//! let endpoint = MergeRequests::builder().project(42).build()?;
110//! let op = gitlab.paged_op(endpoint, Pagination::All);
111//! // op.execute(..) returns a Value::Array concatenating every page
112//! # Ok(())
113//! # }
114//! ```
115
116mod client;
117pub mod endpoints;
118mod operation;
119mod paged_operation;
120
121pub use client::GitLab;
122pub use gitlab;
123pub use operation::GitLabOp;
124pub use paged_operation::GitLabPagedOp;